Closed
Description
Sample code (using RxJava 2.0.4):
Observable.just(1, 2, 3, 4, 5)
.concatMapEager(i -> {
System.out.println("Processing " + i);
return i == 3 ? Observable.just(i) : Observable
.just(i)
.delay(1, TimeUnit.MILLISECONDS, Schedulers.io());
})
.observeOn(Schedulers.io())
.subscribe(i -> System.out.println("Value: " + i));
Expected output:
Processing 1
Processing 2
Processing 3
Processing 4
Processing 5
Value: 1
Value: 2
Value: 3
Value: 4
Value: 5
Actual output:
Processing 1
Processing 2
Processing 3
Processing 4
Processing 5
Value: 3
Value: 1
Value: 2
Value: 4
Value: 5
As you can see the order is incorrect. This is due to the fact that the item 3
is mapped to a Callable
source which won't wait for the previous observables.