question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

what is the diference between flatmap and concatmap?

See original GitHub issue
  1. what is the diference between flatmap and concatmap?
  2. `A.concatmap(b).subscribe(subscriber)``, if the b call the onComplete, subsriber’s onComplete will not be invoked? why? the same as flatmap.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

12reactions
benjchristensencommented, Apr 29, 2015

Marble diagrams showing the difference:

concatMap is sequential: http://reactivex.io/RxJava/javadoc/rx/Observable.html#concatMap(rx.functions.Func1) flatMap is concurrent: http://reactivex.io/RxJava/javadoc/rx/Observable.html#flatMap(rx.functions.Func1)

flatmap

concatmap

Note the interleaving on flatMap.

3reactions
akarnokdcommented, Apr 29, 2015
  1. concatMap ‘runs’ only a single source Observable at a time whereas flatMap subscribes to many of them and if those Observables are async, you get async execution and interleaved emissions between Observables, but values from each of the Observables retain the relative order to each other.
  2. if you produce normal, terminating observables in the function b and A is also terminating properly, then you should get an onCompleted() event. Do you have a test case which exhibits the behavior you mentioned?
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between concatMap and flatMap in ...
FlatMap takes emissions from source observable, then create new observable and merge it to original chain, while concatMap concat it to original chain....
Read more >
RxJava: FlatMap, SwitchMap and ConcatMap differences ...
FlatMap. Lets start with a simple Java unit test that is testing flatMap operator. · SwitchMap. The same test, the same conditions, but...
Read more >
Webflux - flatmap vs concatmap | full-stack front/>
What is a difference between flatMap and concatMap? It's really, important to understand a difference. I'll try to explain it as simple as ......
Read more >
RxJava Observable tranformation: concatMap() vs flatMap().
flatMap() uses MERGE operator while concatMap() uses CONCAT operator meaning that the last one cares about the order of the elements, so keep...
Read more >
RxJava: flatMap() vs. concatMap() vs. concatMapEager()
flatMap() should be your first weapon of choice. It allows efficient concurrency with streaming behavior. But be prepared to receive results out ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found