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




边栏推荐
- Proe/Creo家电产品结构设计规范-电煎锅
- 【TcaplusDB知识库】TcaplusDB数据导入介绍
- Summary of qstype class usage (III)
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
- 【TcaplusDB知识库】TcaplusDB系统用户组介绍
- I.MX6ULL启动方式
- [tcapulusdb knowledge base] Introduction to tcapulusdb table data caching
- 微软云 (Microsoft Cloud) 技术概述
- Uniform Asymptotics by Alexei
- "24 of the 29 students in the class successfully went to graduate school" rushed to the hot search! Where are the remaining five?
猜你喜欢

【TcaplusDB知识库】TcaplusDB常规单据介绍

从零开始搭建物联网系统

Native JS implements page scroll bar loading data and page drop-down loading content

Build the Internet of things system from scratch

Oracle group statistics query

Imeta: a collection of imagegp+ video tutorials of high-value drawing websites, which has been cited 360 times (220625 updates)

“全班29人24人成功读研”冲上热搜!剩下的5个人去哪了?

Prevent being rectified after 00? I. The company's recruitment requires that employees cannot sue the company
![[methodot topic] what kind of low code platform is more suitable for developers?](/img/1e/934b7e013db400332bc77c081f9f29.png)
[methodot topic] what kind of low code platform is more suitable for developers?

Redis 分布式锁15问,看看你都掌握了哪些?
随机推荐
Interview shock 60: what will cause MySQL index invalidation?
VPT Model Video Explanation
JSP custom tag
【TcaplusDB知识库】TcaplusDB系统管理介绍
Wait, how do I use setmemorylimit?
Unity Shader学习(一)认识unity shader基本结构
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
[methodot topic] what kind of low code platform is more suitable for developers?
【TcaplusDB知识库】TcaplusDB单据受理-事务执行介绍
VPT模型视频讲解
[tcapulusdb knowledge base] Introduction to tcapulusdb analytical text export
"24 of the 29 students in the class successfully went to graduate school" rushed to the hot search! Where are the remaining five?
Qstype implementation of self drawing interface project practice (I)
After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
In depth analysis of error solutions and problems in dynamic loading of unity shadow and outline components
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.labels参数在可视化图像中为强调线添加标签信息
Redis 分布式锁15问,看看你都掌握了哪些?
After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
Deep understanding of happens before principle
信息学奥赛一本通 1332:【例2-1】周末舞会