flatMap, concatMap problem on Android 26
See original GitHub issueI am using the lastest version RxJava, and I found that below code run on android 26 has problem-lose event.
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
e.onNext(1);
e.onNext(2);
e.onNext(3);
}
}).concatMap(new Function<Integer, ObservableSource<String>>() {
@Override
public ObservableSource<String> apply(Integer integer) throws Exception {
List<String> list = new ArrayList<>();
for (int i = 0; i < 3; i++) {
list.add("I am value " + integer);
}
int delayTime = (int) (1 + Math.random() * 10);
return Observable.fromIterable(list).delay(delayTime, TimeUnit.MILLISECONDS);
}
}).subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
Log.i(TAG, "concatMap: accept:" + s);
}
});
The run result on android-26(Android 8 emulator)(every observable lose a event):
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:13:54.354 11726-11726/? I/MainActivity: concatMap: accept:I am value 3
The run result on android-25(Android 7.1 emulator):
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 1
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 2
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3
07-30 15:15:26.981 4756-4756/? I/MainActivity: concatMap: accept:I am value 3
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
RxJava - flatmap vs concatMap - why is ordering the same on ...
So i did a test and created a simple stream of integers and wanted to see in what order they would be emitted....
Read more >Unordered sequence when using a map in a zip #3221 - GitHub
I'm having a weird issue with RxJava where items come in the wrong order when one of the zip sources is doing a...
Read more >Transform: FlatMap and ConcatMap - Educative.io
The .flatMap() operator is another very common operator used to transform emissions from an Observable . The stream is transformed by applying a...
Read more >Understanding Map, FlatMap, SwitchMap and ConcatMap | by ...
FlatMap can interleave items while emitting i.e the emitted items order is not maintained. ConcatMap preserves the order of items.
Read more >40 RxJava interview questions (and answers) - Vesko Iliev
What error handling operators do you know in RxJava? ... What's the difference between flatMap(), concatMap() and switchMap()?.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks like there is a feature that hides/ignores duplicate log lines. I get this for the missing entries:
If I change the printed item:
I get all items.
Stackoverflow.
Ok, I got. Thank you very much. 😊