当前位置:网站首页>source observable 发生错误之后会直接进入到catchError operator 而不是按照pipe里面的顺序处理之后再进入catchError
source observable 发生错误之后会直接进入到catchError operator 而不是按照pipe里面的顺序处理之后再进入catchError
2022-06-10 11:08:00 【zsy_1991】
catchError 使用笔记
我一直以为source observable 即使发生错误之后, 也会按照pipe里面的operator 的顺序处理之后再进入catchError, 其实不是的,是跳过前面的operator 处理,直接被catchError operator catch 住。例子如下:
const example$ = new Subject<number>();
// 当source observable 发生错误,pipe 里面的operator 都不走了,直接走catachError
example$.pipe(
map(x => {
console.log(x); // 当source observable 发生错误之后,此句不会执行
return x + 1;
}),
catchError(error => {
console.log(error);
throw 'excute ' + error + ' failed';
})
).subscribe(
next => {
console.log('value=', next);
},
error => {
console.log('had error: ', error);
}
);
example$.next(1);
example$.error(2);
打印结果如下:
map 1
value= 2
catchError 2
had error: excute 2 failed
边栏推荐
- Fcpx plug-in: premiumvfx animation presets v1.0.1 Special Edition
- Linked list, stack, queue
- SaaS management system for digital commerce cloud business service industry: to achieve efficient business collaboration and help enterprises improve their digital transformation
- Use matlab to generate COE files of sine wave, triangular wave and square wave
- Recursive traversal and non recursive traversal of binary tree (C language version)
- 保温热水更方便,日常泡奶的小神器,七彩叮当无线便携式调奶器上手
- 高性能计算(2)——万丈高楼平地起
- Vs code supports configuring remote synchronization
- golang CLI框架--cobra
- Day 2 linked list (simple)
猜你喜欢

保温热水更方便,日常泡奶的小神器,七彩叮当无线便携式调奶器上手

Modstartcms enterprise content site building system (supporting laravel9) v4.1.0

中国赛宝的面经

Northrop Grumman has passed the registration: the annual revenue is 600million, and Wu Jie, the actual controller, is an American

Conversion between binary, octal, decimal and hexadecimal (integer plus decimal)

H.265编码原理入门

企评家分不同维度解析:湖南长城科技信息有限公司企业成长性

Transfer of 30% equity of Zhuhai Gaoyuan Electric Energy Technology Co., Ltd., shared by tamigou

音质出色的降噪旗舰,女毒必选,贝壳王子MO3体验

渡远户外冲刺深交所:年营收3.5亿 林锡臻家族色彩明显
随机推荐
数商云商业服务业SaaS管理系统:实现高效业务协作,助力企业完善数字化转型之路
杰理之BLE 传输速率【篇】
Use matlab to generate COE files of sine wave, triangular wave and square wave
Is the online account opening channel reliable? Is it safe?
Modstartcms enterprise content site building system (supporting laravel9) v4.1.0
PID光离子化检测器用于电厂压缩空气含油量的在线监测
【BUUCTF】[Zer0pts2020]Can you guess it?
NoClassDefFoundError 和 ClassNotFoundException 有什么区别
pytorch安装教程
Music retrieval system based on SSH
Golang thread safe local map -- GOCACHE
Debugging method of cocoslua in vs2013
Why is your next computer a computer? Explore different remote operations
Software testing quality and assurance
In 2021, the revenue of China's electronic components will be the first, revealing the development path of precision and high quality of Tencent
Digital supply chain collaboration system for digital commerce cloud communication industry: empowering communication enterprises to improve supply business and enhance market competitiveness
牛客面经02
Testing ovn manually based on LXD (by quqi99)
杰理之BLE PB2 不能硬件接地或接到三极管基极【篇】
渡远户外冲刺深交所:年营收3.5亿 林锡臻家族色彩明显