I have two observables and used concatDelayError for sequential processing.
My problem is that onNext and onCompleted are called early before processing. How do I know that all processing has been completed with concatDelayError?
Psudo code:
public Observable<Integer> concat(){
int x = 10;
int y = 20;
Observable obx = Observable.create(emitter -> {
try {
int x = doSomeThing();
emitter.onNext(x);
emitter.onCompleted();
} catch (SQLiteException e) {
emitter.onError(e);
}
}, Emitter.BackpressureMode.BUFFER);
Observable oby = Observable.create(emitter -> {
try {
int y = doSomeThing();
emitter.onNext(y);
emitter.onCompleted();
} catch (SQLiteException e) {
emitter.onError(e);
}
}, Emitter.BackpressureMode.BUFFER);
Observable concated = Observable.concatDelayError(ob1,ob2)
.compose(applySchedulers())
.replay().autoConnect();
}
//somewhere else
concat().subscribe(mReplaySubject);
//somewhere else
mReplaySubject.subscribe(new Observer<Integer>() {
@Override
public void onCompleted() {
launchActivity(SplashActivity.this, HomeActivity.class);
SplashActivity.this.finish();
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onNext(Integer value) {
}
});
I am using reply() with autoConnect() and subscribing over ReplySubject as I need to share single subscription.