Rxjava: rx.Single - why no `doOnNext()`?

Created on 29 Sep 2015  路  3Comments  路  Source: ReactiveX/RxJava

I have a Single<?> that I would like to call .doOnNext() on. Why is this omitted? I get why .doOnCompleted() does not exist, but I want to call a void action once and there seems to be no simple way to do this with rx.Single

Technically I could call .map(), do my thing, and return the same object - but that seems like too much overhead. Or call .toObservable().doOnNext().toSingle(), but I cannot imagine that is too efficient.

Feature-Request Question

Most helpful comment

The doOnX matches the parent reactive type's terminology, thus Single has onSuccess -> doOnSuccess. Same for v2 Maybe.onSuccess.

All 3 comments

Hi. The class received too little attention after it has been added to the library. The 1.x operators are kind of hanging off the Observable so currently you can't do better than map().

If you are interested, you can port back operators from the 2.x version (https://github.com/ReactiveX/RxJava/blob/2.x/src/main/java/io/reactivex/Single.java#L1073)

So I guess doOnSuccess() is the equivalent in Single for doOnNext() of Observable?

The doOnX matches the parent reactive type's terminology, thus Single has onSuccess -> doOnSuccess. Same for v2 Maybe.onSuccess.

Was this page helpful?
0 / 5 - 0 ratings