0

Imagining there is Observable A emitting

a1, a2, a3, a4...

A.flatMap(a -> f(a)) will emit items in unpredictable order, for example:

fa3, fa1, fa2, fa4...

How could I get results in order like below?

fa1, fa2, fa3, fa4...

ConcatMap can return the result I want, but it processes streams in sequential order, which is not effective in time consuming. I need something like concatMap with parallel processing ability. Any solution? Thanks.

Hoang Nguyen Huu
  • 1,202
  • 17
  • 17

1 Answers1

1

You can use concatMapEager, which buffers emission and produce items sequentially.

zella
  • 4,645
  • 6
  • 35
  • 60