https://www.learnrxjs.io/learn-rxjs/operators/transformation/mergemap

This operator is best used when you wish to flatten an inner observable but want to manually control the number of inner subscriptions.

使用场合:当您希望展平内部 observable 但想要手动控制内部订阅的数量时

For instance, when using switchMap each inner subscription is completed when the source emits, allowing only one active inner subscription. In contrast, mergeMap allows for multiple inner subscriptions to be active at a time. Because of this, one of the most common use-case for mergeMap is requests that should not be canceled, think writes rather than reads. Note that if order must be maintained concatMap is a better option.

例如,当使用 switchMap 时,每个内部订阅在源发出时完成,只允许一个活动的内部订阅。 相比之下,mergeMap 允许同时激活多个内部订阅。 因此,mergeMap 最常见的用例之一是不应取消的请求,认为是写入而不是读取。 请注意,如果必须维护顺序,则 concatMap 是更好的选择。

注意内存泄漏问题。

Be aware that because mergeMap maintains multiple active inner subscriptions at once it’s possible to create a memory leak through long-lived inner subscriptions. A basic example would be if you were mapping to an observable with an inner timer, or a stream of dom events. In these cases, if you still wish to utilize mergeMap you may want to take advantage of another operator to manage the completion of the inner subscription, think take or takeUntil. You can also limit the number of active inner subscriptions at a time with the concurrent parameter

由于 mergeMap 一次维护多个活动的内部订阅,因此可能会通过长期存在的内部订阅造成内存泄漏。 一个基本示例是,如果您要映射到具有内部计时器的 observable 或 dom 事件流。 在这些情况下,如果您仍然希望使用 mergeMap,您可能希望利用另一个操作符来管理内部订阅的完成,考虑 take 或 takeUntil。 您还可以使用 concurrent 参数限制一次活动内部订阅的数量。

RxJS mergeMap 学习笔记相关推荐

  1. RxJs SwitchMap 学习笔记

    网址:https://www.learnrxjs.io/learn-rxjs/operators/transformation/switchmap The main difference betwee ...

  2. Rxjs merge 学习笔记

    官方链接:https://rxjs-dev.firebaseapp.com/api/index/function/merge Creates an output Observable which co ...

  3. rxjs operator学习笔记

    Pipeable Operators are the kind that can be piped to Observables using the syntax observableInstance ...

  4. 《Angular4从入门到实战》学习笔记

    <Angular4从入门到实战>学习笔记 腾讯课堂:米斯特吴 视频讲座 二〇一九年二月十三日星期三14时14分 What Is Angular?(简介) 前端最流行的主流JavaScrip ...

  5. RxJava学习笔记---简单使用

    如果觉得一篇文章写得好,不要放到收藏夹里面,马上把它看完,如果两天内还没开始看,那就可以删掉了 如果觉得一样技术很好,那就马上去学,不要拖延,不要找借口.如果你一周内还没开始行动,还不如坦荡点放弃 恰 ...

  6. 《Angular4从入门到实战》学习笔记(图文)

    <Angular4从入门到实战>学习笔记 腾讯课堂:米斯特吴 视频讲座 二〇一九年二月十三日星期三14时14分 What Is Angular?(简介) 前端最流行的主流JavaScrip ...

  7. Angularjs2 学习笔记

    angularjs2 学习笔记(一) 开发环境搭建   开发环境,vs2013 update 5,win7 x64,目前最新angular2版本为beta 17 第一步:安装node.js 安装nod ...

  8. Angular官网学习笔记

    Angular官网学习笔记 一.Angular概述 **什么是Angular:**一个基于TypeScript构建的开发平台包括: 一个基于组件的框架,用于构建可伸缩的Web应用 一组完美集成的库,涵 ...

  9. PyTorch 学习笔记(六):PyTorch hook 和关于 PyTorch backward 过程的理解 call

    您的位置 首页 PyTorch 学习笔记系列 PyTorch 学习笔记(六):PyTorch hook 和关于 PyTorch backward 过程的理解 发布: 2017年8月4日 7,195阅读 ...

最新文章

  1. 【Ubuntu】Ubuntu14.04添加163的源
  2. golang微信公众号请求获取信息
  3. MATLAB红色分量图如何合成,如何修改一张图片中红色分量的值?
  4. c 调用java的dll_Windows下java调用c的dll动态库--Dev_Cpp编译c生成dll
  5. 在Linux 6上使用UDEV解决RAC ASM存储设备名问题
  6. SQL查询【根据生日计算】
  7. PHP开发框架[国内框架]
  8. C语言(记录)——内存相关_2:内存的编址与管理
  9. linux命令vi作用,详解Linux常用命令的用法(二)――――文本编辑器命令vi/vim
  10. Mac版微信支持朋友圈了!微信内测版体验感
  11. 活着只是你幸运--512汶川大地震募捐倡议
  12. Mybatis批量保存或更新数据
  13. 基于python下django框架 实现校园二手书籍交易系统详细设计
  14. 基于wincc的虚拟电梯设计_基于WinCC的电梯PLC控制仿真.doc
  15. 数电课程设计数字钟c语言编程,数电数字钟设计,含源码
  16. java:从淘宝获取优惠券的、带推广链接的、带淘口令的商品信息
  17. 最全的常用正则表达式--包含校验数字、字符、一些特殊的需求等等
  18. VS2019 Xamarin.Android开发蓝牙通讯
  19. 系统崩溃分析 - vmcore 加载到 Trace32
  20. Icpc 沈阳 Bitwise Exclusive-OR Sequence

热门文章

  1. 拆半查找的递归和非递归算法
  2. Redis数据恢复--误删数据后一次吓尿的经历
  3. NYOJ 1068 ST(段树 为段更新+间隔总和)
  4. MySql 存储过程实例(附完整注释)
  5. 看反病毒专家对EICAR检测代码的专业解读
  6. go语言中go+select的理解
  7. BZOJ 1500 维修数列
  8. 返回变量内容的错误示例和正确返回的4种方法
  9. 报表查询——自动刷新数据,双击明细打开关联作业
  10. Hive(三)hive的高级操作