nic
04/18/2019, 7:21 PMgetSomeObservable().flatMapSingle { t -> performAPICallWithData(t) }
I don't want to performAPICallWithData
until the first one has completed, and I want to use the result from performAPICallWithData
to determine wether I should perform the next one or complete everythingalexsullivan114
04/18/2019, 8:54 PMval observable = getSomeObservable().share()
observable.take(1).switchMap { t -> performApiCallWithData(t).flatMap { if (it.rightKindOfData) observable.skip(1) else Observable.empty() }
switchMap
there since that'll probably not compile because you're using a single. Could just be flatMap
, doesn't make a difference in this casenic
04/18/2019, 9:51 PMgetSomeObservable().map { t ->
performApiCallWithData(t).blockingGet()
}.takeWhile {
!it.rightKindOfData
}.ignoreElements()
Seems to be working at the moment, although I'm open to alternative approaches. Does that make sense to you?alexsullivan114
04/19/2019, 11:23 AMblockingGet
since it defeats a bit part of the purpose. That being said if it works at this point I'd say it's fine.nic
04/19/2019, 5:07 PMconcatMapSingleDelayError
which seems to work perfectly.
it ends up like
getSomeObservable().concatMapSingleDelayError { t ->
performApiCallWithData(t)
}.takeWhile {
!it.rightKindOfData
}.ignoreElements()
Maps the upstream items into SingleSources and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both this Observable and all inner SingleSources terminate.
which is exactly what I was looking for. The key term being subscribes to them one after the other succeeds or fails
alexsullivan114
04/19/2019, 7:43 PM