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




边栏推荐
- 政策关注 | 加快构建数据基础制度,维护国家数据安全
- iMeta:高颜值绘图网站imageGP+视频教程合集,已被引360次(220625更新)
- AUTOCAD——三种修剪方式
- 中科院微生物所招聘青年PI 20比特,2百萬安家費,千萬啟動經費(長期有效)
- 等等, 怎么使用 SetMemoryLimit?
- Open source model library of flying propeller industry: accelerating the development and application of enterprise AI tasks
- 15+城市道路要素分割应用,用这一个分割模型就够了!
- [tcapulusdb knowledge base] tcapulusdb doc acceptance - create business introduction
- istio相关资料
- [tcapulusdb knowledge base] Introduction to tcapulusdb data import
猜你喜欢

Matlab exercises - create 50 rows and 50 columns of all zero matrix, all 1 matrix, identity matrix, diagonal matrix, and output the 135 element of the matrix.

Metadata of database

从零开始搭建物联网系统

面试突击60:什么情况会导致 MySQL 索引失效?

Popular science of device review: popular science of innovative medical device series - sternum plate products

飞桨产业级开源模型库:加速企业AI任务开发与应用

15+ urban road element segmentation application, this segmentation model is enough!

Summary of qstype class usage (II)
![[tcapulusdb knowledge base] Introduction to tmonitor system upgrade](/img/04/b1194ca3340b23a4fb2091d1b2a44d.png)
[tcapulusdb knowledge base] Introduction to tmonitor system upgrade

杰理之DAC输出方式设置【篇】
随机推荐
The wonderful use of 0 length array in C language
In depth analysis of error solutions and problems in dynamic loading of unity shadow and outline components
QStyle类用法总结(三)
杰理之IO 口中断使用注意事项【篇】
【TcaplusDB知识库】TcaplusDB单据受理-创建业务介绍
R语言使用epiDisplay包的poisgof函数对泊松回归(Poisson Regression)执行拟合优度检验、检验是否存在过度离散问题(overdispersion)
Jerry's adding timer interrupt [chapter]
Llvm family (1) - Introduction to llvm
LeetCode 522 最长特殊序列II[枚举 双指针] HERODING的LeetCode之路
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)
Institute of Microbiology, Chinese Academy of Sciences recruited 20 young PI, with a resettlement fee of 2million yuan and a start-up fund of 10million yuan (long-term effective)
Co jump
i.mx6ull(单片机) c语言环境搭建
VPT Model Video Explanation
After Jerry's sleep, the regular wake-up system continues to run without resetting [chapter]
Leetcode 729. My schedule I (awesome, solved)
Go zero micro Service Practice Series (VII. How to optimize such a high demand)
杰理之无缝循环播放【篇】
【TcaplusDB知识库】TcaplusDB-tcapsvrmgr工具介绍(一)
Detailed explanation of interprocess communication