Like switchMap and mergeMap, concatMap is a shortcut for map() followed by a concatAll(). In this lesson we will explore this RxJS operator and its properties.

const clickObservable = Rx.Observable
.fromEvent(document, 'click'); function performRequest() {
return fetch('https://jsonplaceholder.typicode.com/users/1')
.then(res => res.json());
} const emailObservable = clickObservable
.concatMap(click => performRequest(),
(click, res) => res.email); // concatMap = map ... + ... concatAll
// mergeMap
// switchMap emailObservable
.subscribe(email => console.log(email));

concatMap happens one after the other, the same as mergeAll(1):

const emailObservable = clickObservable
.mergeMap(click => performRequest(),
(click, res) => res.email,
);

So the main different between switchMap, mergeMap, concatMap are about concurrency...

  • switchMap: has cancel previous request functionaility.
  • mergeMap: allows num of concurrency requests
  • concatMap: the same as mergeAll(1), only allow one request at a time

最新文章

  1. PCA数据降维
  2. 无后台的网站 内容暂存json
  3. java疑问-继承问题
  4. createjs 入门之EaselJs 绘制图片Bitmap
  5. leetcode-【hard】273. Integer to English Words
  6. PHPExcel使用体会
  7. 迅为4412开发板Linux驱动教程——总线_设备_驱动注册流程详解
  8. PostgreSQL Monitor pg_activity
  9. HP QC IE11不支持( win7 64位 无法安装)解决方法
  10. raft 一致性算法
  11. matlab 相关性分析
  12. Ubuntu命令行连接WPA/WPA2无线网线
  13. java.lang.IllegalArgumentException: Request header is too large
  14. Java 读书笔记 (七) 变量
  15. Git初识学习
  16. 后端自测必备神器-PostMan
  17. LeetCode - Reorganize String
  18. [转]小程序web-view组件
  19. jQuery UI dialog插件出错信息:$(this).dialog is not a function
  20. POJ2975:Nim(Nim博弈)

热门文章

  1. jodd-servlet工具集锦
  2. 淘宝的css初始化代码
  3. Java学习笔记六 常用API对象二
  4. 数组-reduce方法
  5. java8新增特性(二)----函数式接口(Functional)
  6. CentOS卸载Apache方法
  7. 84.setlocale
  8. StringBuilder和String的区别
  9. 连接mongodb,kafka异步处理代码
  10. 安装orabbix