I have this very simple RxJava example
List<Integer> arrayIntegers = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
Observable.fromIterable(arrayIntegers).map(i -> {
Log.d("RxJava", "map i = " + i);
return i;
}).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).
subscribe(new DisposableObserver<Integer>() {
@Override
public void onNext(Integer i) {
Log.d("RxJava", "next i = " + i);
}
@Override
public void onError(Throwable e) {}
@Override
public void onComplete() {
Log.d("RxJava", "Completed");
}
});
Which gives this result..
D/RxJava: map i = 1
D/RxJava: map i = 2
D/RxJava: map i = 3
D/RxJava: map i = 4
D/RxJava: map i = 5
D/RxJava: next i = 1
D/RxJava: next i = 2
D/RxJava: next i = 3
D/RxJava: next i = 4
D/RxJava: next i = 5
What I was expecting though is something more like this
D/RxJava: map i = 1
D/RxJava: next i = 1
D/RxJava: map i = 2
D/RxJava: next i = 2
D/RxJava: map i = 3
D/RxJava: next i = 3
D/RxJava: map i = 4
D/RxJava: next i = 4
D/RxJava: map i = 5
D/RxJava: next i = 5
Could someone explain what I am doing wrong which is causing my order to be incorrect?