I'm using RxJava on Android. I have a pretty quite simple piece of code here : Observable> observable =
Observable.create((ObservableOnSubscribe<Observable<Boolean>>) emitter1 -> {
emitter1.onNext(doSomething());
emitter1.onComplete();
}).concatMap(accessToken -> Observable.create((ObservableOnSubscribe<Observable<Boolean>>) emitter2 -> {
emitter2.onNext(doSomethingElse());
emitter2.onComplete();
}).observeOn(Schedulers.io()).subscribeOn(Schedulers.io()));
What I want to do =>
-> Start A
-> A is processing
-> A is ending
-> Start B
-> B is processing
-> B is ending
what I actually got :
-> Start A
-> A is processing
-> Start B
-> B is processing
-> A is ending
-> B is ending
But I thougt concatMap was waiting for the first observable to end before lauching the next one... ?
Please try like this :
Observable.create((ObservableOnSubscribe<Observable<Boolean>>) emitter1 -> {
emitter1.onNext(doSomething());
emitter1.onComplete();
}).concatMap(accessToken -> Observable.create((ObservableOnSubscribe<Observable<Boolean>>) emitter2 -> {
emitter2.onNext(doSomethingElse());
emitter2.onComplete();
})).observeOn(Schedulers.io()).subscribeOn(Schedulers.io());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.