Closed Rainer-Lang closed 8 years ago
You can use one of the doOnX methods :
doOnNext() doOnCompleted() doOnError() doOnEach()
In your case it's doOnCompleted() :
@WassimBenltaief So I should complete/end the stream and make within doOnCompleted my method call?
If you want to execute the method once the stream ends succesfully so doOnCompleted is the right place. If your expected value is in the middle of the stream so doOnNext with a "check" inside the provided Action is the appropriate.
@Rainer-Lang @WassimBenltaief is 💯 right.
executing a single method can be done in many ways. it depends at which point you want the single method to be executed. in all likelihood you would use a variant of the doOnX
as suggested.
Have a look at the repository to see the different ways doOnNext
is used or doOnSubscribe
etc.
I'm closing this issue as it has nothing to do with the examples in this repo.
@kaushikgopal It wasn't executing a method. It was about executing a method after a change of an Observable to a specific value and THAN execute a method only once and finish. But you're right, @WassimBenltaief gave me a hint. BUT, maybe this could be also something for your repo. ;)
After getting a specfic value from an Observable, I would like to execute a method only once. -> on Completed()
How could this be possible?