当前位置:网站首页>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));




边栏推荐
- Uniform Asymptotics by Alexei
- Native JS implements page scroll bar loading data and page drop-down loading content
- Detailed explanation of interprocess communication
- matlab习题 —— 创建 50 行 50 列全零矩阵、全 1 矩阵、单位矩阵、对角矩阵,输出矩阵第135号元素。
- 【TcaplusDB知识库】TcaplusDB业务数据备份介绍
- Open source model library of flying propeller industry: accelerating the development and application of enterprise AI tasks
- 【TcaplusDB知识库】TcaplusDB OMS业务人员权限介绍
- 杰理之无缝循环播放【篇】
- Write it down once Net analysis of a property management background service stuck
- Codeforces Round #786 (Div. 3) ABCDE
猜你喜欢

【TcaplusDB知识库】TcaplusDB单据受理-创建游戏区介绍
![[tcapulusdb knowledge base] Introduction to tmonitor stand-alone installation guidelines (II)](/img/6d/8b1ac734cd95fb29e576aa3eee1b33.png)
[tcapulusdb knowledge base] Introduction to tmonitor stand-alone installation guidelines (II)

Ci/cd automatic test_ 16 best practices for CI / CD pipeline to accelerate test automation

【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍

Write it down once Net analysis of a property management background service stuck

iMeta:高颜值绘图网站imageGP+视频教程合集,已被引360次(220625更新)

一篇抄十篇,CVPR Oral被指大量抄袭
![[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (II)](/img/0a/742503e96a9b51735f5fd3f598b9af.png)
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (II)

15+城市道路要素分割应用,用这一个分割模型就够了!

Glide缓存机制
随机推荐
Ci/cd automatic test_ 16 best practices for CI / CD pipeline to accelerate test automation
机器学习系统在生产中的挑战
QStyle实现自绘界面项目实战(一)
Proe/Creo家电产品结构设计规范-电煎锅
【TcaplusDB知识库】TcaplusDB运维单据介绍
[tcapulusdb knowledge base] tcapulusdb system user group introduction
[worthy of collection] centos7 installation MySQL complete operation command
ci/cd自动化测试_CI / CD管道加快测试自动化的16种最佳实践
从零开始搭建物联网系统
Microsoft cloud technology overview
Redis 分布式锁15问,看看你都掌握了哪些?
Wait, how do I use setmemorylimit?
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;)
【TcaplusDB知识库】TcaplusDB-tcaplusadmin工具介绍
After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
Leetcode 729. 我的日程安排表 I(提供一种思路)
等等, 怎么使用 SetMemoryLimit?
"Internet +" contest topic hot docking | I figure to understand 38 propositions of Baidu
R语言fpc包的dbscan函数对数据进行密度聚类分析、plot函数可视化聚类图
0 basic understanding of how e-commerce systems connect with payment channels