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.

Rename mergeMap back to flatMap for v6?

See original GitHub issue

Prior to v5, the mergeMap operator was named flatMap, which is a term coined from functional programming in general. While v5 was being developed there was a lot of discussion and in the end it was thought by a majority of the people involved that renaming it to mergeMap would help newcomers better grasp what it does, as well as align with the names of the other merge operators.

Now that’s been a couple years with mergeMap, and rxjs’s popularity has continued to explode, IMO mergeMap hasn’t been as helpful as predicted, and I think we underestimated how many people have prior knowledge of the term flatMap, and prefer it over mergeMap. This may also change drastically if JavaScript gets Array.prototype.flatMap as proposed. Additional facts: .NET calls it SelectMany but all other Rx implementations I can find use flatMap

@staltz has a great summary below of why it was felt flatMap was too ambiguous in the context of Rx: https://github.com/ReactiveX/rxjs/issues/3006#issuecomment-339787756.

I’d like to open discussions on the possibility of renaming mergeMap back to flatMap for v6. To be 100% clear, I have no official sway in the decision, except that I might bribe some of the core team members. 😈.

Civil arguments for or against are of course welcome, but please don’t comment with +1 or thumbs up šŸ˜† Use the github ā€œreactionsā€ on this post below

#333

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:63
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

25reactions
staltzcommented, Oct 26, 2017

šŸ‘Ž because functional programming’s flatMap is ambiguous in RxJS, it has these options: switchMap, mergeMap, concatMap, exhaustMap are all ā€œflatMapā€.

In fact, Array.prototype.flatMap is much more like Rx concatMap than it is like mergeMap.

I’ve been teaching these operators in workshops and students really appreciate the consistency

  • mergeAll – mergeMap
  • concatAll – concatMap
  • switch – switchMap
7reactions
cartantcommented, Oct 26, 2017

How about renaming it to flatMap, making mergeMap the alias, and then switching the names around again for v7?

Edit: 😜

Read more comments on GitHub >

github_iconTop Results From Across the Web

rxjs flatmap missing - observable
Show activity on this post. With RxJS 5.5+, the flatMap operator has been renamed to mergeMap . Instead, you should now use the...
Read more >
Understanding flatMap, mergeMap and toArray operators ...
mergeMap () operator takes the user output from the previous operator(flatMap). The user identifier is read to perform a request to obtain theĀ ......
Read more >
flatMap - RxJS
Renamed to mergeMap . Will be removed in v8. ... Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0. Version...
Read more >
mergeMap / flatMap
This operator is best used when you wish to flatten an inner observable but want to manually control the number of inner subscriptions....
Read more >
[Solved]-rxjs flatmap missing-rx.js
Using rxjs v6.5.1 ... other logic return rp(options); // returns promise }) ); ... With RxJS 5.5+, the flatMap operator has been renamed...
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