当前位置:网站首页>Rxjs mergeMap 的使用场合
Rxjs mergeMap 的使用场合
2022-06-27 11:22:00 【InfoQ】
- flatMap 是 mergeMap 的别名。
- 如果一次只能激活一个内部订阅,请使用 switchMap.
- 如果内部 observables 的发射和订阅顺序很重要,请使用 concatMap.
import { fromEvent, of } from 'rxjs';
import { mergeMap, delay } from 'rxjs/operators';
// faking network request for save
const saveLocation = location => {
return of(location).pipe(delay(500));
};
// streams
const click$ = fromEvent(document, 'click');
click$
.pipe(
mergeMap((e: MouseEvent) => {
return saveLocation({
x: e.clientX,
y: e.clientY,
timestamp: Date.now()
});
})
)
// Saved! {x: 98, y: 170, ...}
.subscribe(r => console.log('Saved!', r));




边栏推荐
- Codeforces Round #786 (Div. 3) ABCDE
- [worthy of collection] centos7 installation MySQL complete operation command
- 力扣(LeetCode)177. 第N高的薪水(2022.06.26)
- 【TcaplusDB知识库】TcaplusDB常规单据介绍
- Uniform Asymptotics by Alexei
- KDD 2022 | 基于分层图扩散学习的癫痫波预测
- Leetcode 729. 我的日程安排表 I(提供一种思路)
- 15+城市道路要素分割应用,用这一个分割模型就够了!
- C語言0長度數組的妙用
- One copy ten, CVPR oral is accused of plagiarizing a lot
猜你喜欢
随机推荐
“互联网+”大赛命题火热对接中 | 一图读懂百度38道命题
VPT模型视频讲解
Jerry's serial port communication serial port receiving IO needs to set digital function [chapter]
杰理之睡眠以后定时唤醒系统继续跑不复位【篇】
JSP自定义标签
Microsoft cloud technology overview
Summary of qstype class usage (III)
Leetcode 522 longest special sequence ii[enumeration double pointer] leetcode path of heroding
KDD 2022 | epileptic wave prediction based on hierarchical graph diffusion learning
Detailed explanation of interprocess communication
Glide缓存机制
Ci/cd automatic test_ 16 best practices for CI / CD pipeline to accelerate test automation
Codeforces Round #786 (Div. 3) ABCDE
After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
【TcaplusDB知识库】TcaplusDB单据受理-建表审批介绍
21: Chapter 3: develop pass service: 4: further improve [send SMS, interface]; (in [send SMS, interface], call Alibaba cloud SMS service and redis service; a design idea: basecontroller;)
Challenges of machine learning system in production
0 basic understanding of how e-commerce systems connect with payment channels
How to deploy jupyterlab in methodot?
Oracle group statistics query







