flatMap, mergeMap, switchMap and concatMap in rxjs?

后端 未结 6 469

Someone, please explain the difference between SwitchMap and FlatMap in terms of Javascript ( in angular perspective, rxjs 5)

In my understanding.

S

6条回答
  •  庸人自扰
    2020-12-02 06:02

    This is at the beginning a bit long to grasp, at least for me.

    Anyways, consider this:

    flatMap IS ANOTHER NAME FOR mergeMap - mergeMap method accepts an optional parameter concurrency, which defines how many Observables can be subscribed at the same time

    concatMap equals mergeMap with concurrency set to 1

    with mergeMap you do not lose any event emitted by the Observables you are merging as you suggested in your answer

    switchMap works as you have described (see this nice article for more details https://blog.angular-university.io/rxjs-switchmap-operator/)

提交回复
热议问题