Solvedrxjs Rename mergeMap back to flatMap for v6?

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: #3006 (comment).

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


21 Answers

✔️Accepted Answer

👎 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

  • mergeAllmergeMap
  • concatAllconcatMap
  • switchswitchMap

Other Answers:

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

Edit: 😜

I've seen enough confusions by having variant of operater in api aurface. While I don't have opinion on this issue itself, I am objecting having two both.

More Issues: