[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 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
[RxJS] Use RxJS concatMap to map and concat high order observables的更多相关文章
- [RxJS] Use RxJS mergeMap to map and merge high order observables
Like RxJS switchMap() is a shortcut for map() and switch(), we will see in this lesson how mergeMap( ...
- [RxJS] Getting Input Text with Map
By default, Inputs will push input events into the stream. This lesson shows you how to use map to c ...
- [RxJS] Implement RxJS `concatMap` by Waiting for Inner Subscriptions to Complete
Unlike mergeMap and switchMap, concatMap focuses on when "inner" subscriptions "compl ...
- [RxJS] Chain RxJS Operators Together with a Custom `pipe` Function using Array.reduce
Instead of writing complex operators, it's usually best to write simple, single-purpose operators th ...
- [RxJS] Implement RxJS `switchMap` by Canceling Inner Subscriptions as Values are Passed Through
switchMap is mergeMap that checks for an "inner" subscription. If the "inner" su ...
- [RxJS] Implement RxJS `mergeMap` through inner Observables to Subscribe and Pass Values Through
Understanding sources and subscribers makes it much easier to understand what's going on with mergeM ...
- [RxJS] Convert RxJS Subjects to Observables
The use of RxJS Subjects is common, but not without problems. In this lesson we will see how they ca ...
- [RxJS] What RxJS operators are
We have covered the basics of what is Observable.create, and other creation functions. Now lets fina ...
- RxJS中高阶操作符的全面讲解:switchMap,mergeMap,concatMap,exhaustMap
RxJS中高阶映射操作符的全面讲解:switchMap, mergeMap, concatMap (and exhaustMap) 原文链接:https://blog.angular-universi ...
随机推荐
- 关于Django的登录系统
首先需要明确的是登录的本质:登录就是服务器确认当前用户的身份,并将数据库中的记录提取匹配 默认的登录系统是用户名密码方式,这种方式很平常,也没什么特别的.这里主要说的是第三方验证登录 通常第三方验证登 ...
- 前台Ajax发送数据给后台
前台发ajax请求给后台 前台代码 let data= [{receiveAdd:receiveAddVal, sendAdd:sendAddVal,distance:distance,goodsNa ...
- ajax获取服务器响应信息
window.onload = function(){ document.getElementById('btn').onclick = function(){ var req = new XMLHt ...
- Android之——图片的内存优化
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46972817 1. 对图片本身进行操作 尽量不要使用 setImageBitmap ...
- 《TCP/IP具体解释卷2:实现》笔记--协议控制块
协议层使用协议控制块(PCB)存放各UDP和TCP插口所要求的多个信息片.Internet协议维护Internet协议控制块 (internet protocol control block)和TCP ...
- RMAN-03002、RMAN-06059
使用RMAN备份的时候无法正常备份,抛出以下错误: RMAN-03002: failure of backup command at 04/20/2015 18:55:45 RMAN-06059: e ...
- LeetCode Algorithm 01_Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The ...
- JS实现时钟效果
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JS里的函数的call()与back()方法
function cat(){} cat.prototype={ food:"fish", say: function(){ alert("I love "+t ...
- [D3] Build a Scatter Plot with D3 v4
Scatter plots, sometimes also known as bubble charts, are another common type of visualization. They ...