mg6maciej
06/05/2017, 9:38 PMyougin
06/06/2017, 7:26 AMmg6maciej
06/06/2017, 7:32 AMmg6maciej
06/06/2017, 7:34 AMObservable.never<Unit>().startWith(Unit)
.yougin
06/06/2017, 8:26 AMyougin
06/06/2017, 8:27 AMmg6maciej
06/06/2017, 8:49 AMyougin
06/06/2017, 6:44 PMObservable
and Completable
isn’t as trivial as I had been thinking about it.
how do you recommend handling a use case like `Observable -> Completable -> Subscriber`:
userClicksObservable.flatMap { save(it).toObservable<Unit>() }.subscribe { // do something }
where save is Completable
?mg6maciej
06/06/2017, 6:47 PMsave
can fail you don't want to do this, cause userClicks will stop working after error.yougin
06/06/2017, 6:49 PMyougin
06/06/2017, 6:50 PMmg6maciej
06/06/2017, 6:52 PMyougin
06/06/2017, 6:52 PMyougin
06/06/2017, 6:53 PMyougin
06/06/2017, 6:53 PMmg6maciej
06/06/2017, 6:53 PMyougin
06/06/2017, 6:54 PMonNext
firedyougin
06/06/2017, 6:54 PMSubscriber
yougin
06/06/2017, 6:55 PMonNext
mg6maciej
06/06/2017, 6:56 PMjust(Unit)
.mg6maciej
06/06/2017, 6:56 PMonNext
when save
completes.yougin
06/06/2017, 6:58 PMCompletable
with flatMap
emitting just(Unit)
, but I realised there’s no items emitted to trigger itmg6maciej
06/06/2017, 6:58 PMyougin
06/06/2017, 7:03 PMmg6maciej
06/06/2017, 7:04 PMsomeCompletable.toObservable<Unit>().concatWith(just(Unit))
doesn't result in onNext
calls?mg6maciej
06/06/2017, 7:05 PMjust(Unit).startWith(someCompletable.toObservable<Unit>())
, but this is the same.yougin
06/06/2017, 7:05 PMconcatMap
which is a different thingyougin
06/06/2017, 7:07 PMyougin
06/06/2017, 7:09 PMyougin
06/06/2017, 7:10 PMmg6maciej
06/06/2017, 7:14 PM.concatWith(just(Unit))
instead of .concatWith { just(Unit) }
?yougin
06/06/2017, 7:15 PMyougin
06/06/2017, 7:15 PMmg6maciej
06/06/2017, 7:15 PMmg6maciej
06/06/2017, 7:16 PMconcatWith { }
is some dark magic.yougin
06/06/2017, 7:16 PMmg6maciej
06/06/2017, 7:17 PM.concatWith { it.onNext(Unit); it.onComplete() }
should work as well 🙂yougin
06/06/2017, 7:19 PMCompletable
with concat
is not a big price to pay compared to splitting the chain into two independent. I mean, the second one requires the same handing as threading, keeping subscriptions, etc.