RX Java – rxjava returns a single, which is completed after execution
•
Java
I'm trying to do the following: return some data as a single, and then execute it after completion Due to single Andthen(), the following code cannot be compiled Operations need to be performed in this order
val single = Single.create<String> { it.onSuccess("result") } val completable = Completable.create { println("executing cleanup") } val together = single.andThen(completable) together.subscribe( { println(it) },{ println(it) } )
Solution
Using flatmap:
single.flatMap(v -> completable.andThen(Single.just(v)))
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码