https://kotlinlang.org logo
Title
k

Keith Mayoral

05/06/2022, 12:05 AM
Hey all, I’m trying to think of a way to have a RxJava2 operator that is something like
Single.amb(sourcesList)
which behaves just like amb when any input Single source succeeds but only errors out after all input sources have failed (as opposed to
amb()
which errors out immediately if the first source to complete errored out)
e

ephemient

05/08/2022, 7:18 AM
been ages since I've looked at rx (why not switch to kotlinx.coroutines?) and I haven't anything setup to test this, but but in principle this shouldn't be too difficult
d

devKshitijJain

06/04/2022, 6:24 PM
Can you not use ErrorResumeNext? I guess it continue with some default item if any of source throw error.
e

ephemient

06/04/2022, 9:54 PM
even if you do something like
Single.amb(sourcesList).retry()
or equivalent with
onErrorResumeNext
, one source failing cancels everything else that's currently in-flight, forcing them to be re-subscribed on retry/resume