exhaustMap: It drop the outter observable, just return the inner observable, and it waits until previous observable complete before emit next observable.

Good for canceling extra network outter request, for example click (outter) request trigger network (inner) request, if network (inner) request is not finished yet, new click (outter) request will be ignored.

Use case: "Save" button, avoid send extra network request to the server.

switchMap: Map to inner observable, cancel previous request.

  // exhaustMap

  @Effect()
login$ = this.actions$
.ofType(Auth.LOGIN)
.map((action: Auth.Login) => action.payload)
.exhaustMap((auth: Authenticate) =>
this.authService
.loginUser(auth.email, auth.password))
.map(user => new Auth.LoginSuccess({user}))
.catch(error => of(new Auth.LoginFailure(error))); // switchMap @Effect()
login$ = this.actions$
.ofType(Auth.LOGIN)
.map((action: Auth.Login) => action.payload)
.switchMap((auth: Authenticate) =>
this.authService
.loginUser(auth.email, auth.password)
.map(user => new Auth.LoginSuccess({user}))
.catch(error => of(new Auth.LoginFailure(error)));
)
.shareReplay(1)

SwitchMap has cancelling logic.

concatMap:

Good for waiting previous network request finished. For example, We have a form, when use is typing, we also want to save the data, send to the server.

Every network request will send in order, and wait pervious network request finished.

[RxJS] exhaustMap vs switchMap vs concatMap的更多相关文章

  1. RxJS中高阶操作符的全面讲解:switchMap,mergeMap,concatMap,exhaustMap

    RxJS中高阶映射操作符的全面讲解:switchMap, mergeMap, concatMap (and exhaustMap) 原文链接:https://blog.angular-universi ...

  2. [RxJS] Use RxJS concatMap to map and concat high order observables

    Like switchMap and mergeMap, concatMap is a shortcut for map() followed by a concatAll(). In this le ...

  3. angular2 学习笔记 ( rxjs 流 )

    RxJS 博大精深,看了好几篇文章都没有明白. 范围牵扯到了函数响应式开发去了... 我对函数式一知半解, 响应式更是第一次听到... 唉...不过日子还是得过...混着过先呗 我目前所理解的很浅,  ...

  4. RxJS——Operators

    RxJS 的操作符(operators)是最有用的,尽管 Observable 是最基本的.操作符最基本的部分(pieces)就是以申明的方式允许复杂的异步代码组合简化. 什么是操作符? 操作符是函数 ...

  5. rxjs简单入门

    rxjs全名Reactive Extensions for JavaScript,Javascript的响应式扩展, 响应式的思路是把随时间不断变化的数据.状态.事件等等转成可被观察的序列(Obser ...

  6. RxJS v6 学习指南

    为什么要使用 RxJS RxJS 是一套处理异步编程的 API,那么我将从异步讲起. 前端编程中的异步有:事件(event).AJAX.动画(animation).定时器(timer). 异步常见的问 ...

  7. RxJS速成 (下)

    上一部分: http://www.cnblogs.com/cgzl/p/8641738.html Subject Subject比较特殊, 它即是Observable又是Observer. 作为Obs ...

  8. ReactiveX 学习笔记(30)操作符辨析

    RxJava: merge/concat/switch RxJS: merge/concat/switch/exhaust RxSwift: merge/concat/switchLatest mer ...

  9. Angular2入门系列教程6-路由(二)-使用多层级路由并在在路由中传递复杂参数

    上一篇:Angular2入门系列教程5-路由(一)-使用简单的路由并在在路由中传递参数 之前介绍了简单的路由以及传参,这篇文章我们将要学习复杂一些的路由以及传递其他附加参数.一个好的路由系统可以使我们 ...

随机推荐

  1. 使用less时的calc()函数问题

    在使用less时写 width:calc(100%-30px); 但在浏览器检查元素的时候总会显示width:70%; 可以在Less中把calc的写法改写成下面这样: width : calc(~& ...

  2. Mongodb 重置密码或创建用户

    1.关闭mongodb  服务 win+r  输入services.msc 回车 找到MongoDB  关闭掉 2.进入到 win +r  输入cmd  进入命令窗口 在进入到mongodb 的安装目 ...

  3. php入门学习笔记

    学习笔记[6.5-6.13] 1.常用命令 打开数据库格式: mysql -h主机地址 -u用户名 -p 重启nginx:sudo /etc/init.d/nginx restart或者service ...

  4. python 将中文转拼音后填充到url做参数并写入excel

    闲着没事写了个小工具,将中文转拼音后填充到url做参数并写如excel 一.先看下演示,是个什么东西 二.代码 代码用到一个中文转拼音的库,库是网上下的,稍微做了下修改,已经找不原来下载的地址了,然后 ...

  5. ats 与 https

    一些证书相关的描述:   https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKe ...

  6. Python星号表达式

    有时候可能想分解出某些值然后丢弃它们,可以使用诸如 _ 或者 ign(ignored)等常用来表示待丢弃值的变量名: record = ('ACME', 50, 123.45, (12, 18, 20 ...

  7. Redis 之消息发布与订阅(publish、subscribe)

    使用办法: 订阅端: Subscribe 频道名称 发布端: publish 频道名称 发布内容 一般做群聊,聊天室,发布公告信息等.

  8. linux最常用的快捷键

    1.ctrl+alt+T 调出命令行界面 2.alt+f4 关闭当前窗口

  9. NFS指定端口,NFS缓存(转载)

    nfs服务端: #编辑/etc/nfsmount.conf,在末尾添加: #RQUOTAD_PORT=30001#LOCKD_TCPPORT=30002#LOCKD_UDPPORT=30002#MOU ...

  10. Html5 WebSocket详细介绍

    什么是WebSocket?看过html5的同学都知道,WebSocket protocol 是HTML5一种新的协议.它是实现了浏览器与服务器全双工通信(full-duplex).HTML5定义了We ...