These are chat archives for ReactiveX/RxJava

2nd
Jan 2018
Phoenix
@wbinarytree
Jan 02 2018 11:33

Hi is there an operator can ignore the onComplete from upstream? for example i use this

Observable.flatmap{
    Observable.just(it)
                            .onErrorReturn{error ->ErrorState(error)}
}

it won't complete when a error occur

Oleh Dokuka
@OlegDokuka
Jan 02 2018 11:55
Unfortunatelly, as far as I know, there is no such operator out of the box, but in Reactor 3 this feature will be included in the next 3.2.x release
Phoenix
@wbinarytree
Jan 02 2018 11:57
Thanks ! what's that operator called then? onErrorReplace or something?
actually it will be called as .errorStrategyContinue, but you may join the discussion and propose and additional resume operator with fallback -> reactor/reactor-core#629
Phoenix
@wbinarytree
Jan 02 2018 12:04
i will keep my flatMap then. Thanks . I will check it out in Project Reactor
Oleh Dokuka
@OlegDokuka
Jan 02 2018 12:04
:+1:
Phoenix
@wbinarytree
Jan 02 2018 12:14

Another question. Is there any operator is equivalent andThen for Completable in Observable? For example i use this really often

API.login
      .doOnNext(//save the login datas)
      .ignoreElements()
      .andThen(//other observable Calls)

I think concatWith is somehow the good one but it need downstream be the same type.

David Karnok
@akarnokd
Jan 02 2018 12:40
Use flatMap to continue with some other type.
API.login
    .doOnNext(loginData -> { /* ... */ })
    .flatMap(loginData -> API.fetchFavorites(loginData.userId))
Phoenix
@wbinarytree
Jan 02 2018 12:44
But it's not guarantee to be called after complete no? Also For example maybe the upstream emit more than one item(instead of login). But ignoreElements().anThen() will called only once after the upstream complete.
Oleh Dokuka
@OlegDokuka
Jan 02 2018 12:46
use .concateMap instead. It guaranties that each call will be executed in order as they come,
Phoenix
@wbinarytree
Jan 02 2018 12:46
yes. Then back to the problem of the same signature in concatMap
Oleh Dokuka
@OlegDokuka
Jan 02 2018 12:48
so if you make a call to external API concate guaraties that the next call will not be executed until previois has been completed
Phoenix
@wbinarytree
Jan 02 2018 12:54
I think concatMap is not the same. .ignoreElements().anThen() will execute only once no matter what number of item emitted by the upstream. but concatMap will map all element to the given transform function
Oleh Dokuka
@OlegDokuka
Jan 02 2018 13:09
Yeah, you are right.