当前位置:网站首页>After an error occurs in the source observable, it will be directly entered into the catchrror operator instead of the sequence in the pipe before entering the catchrror
After an error occurs in the source observable, it will be directly entered into the catchrror operator instead of the sequence in the pipe before entering the catchrror
2022-06-10 11:15:00 【zsy_ one thousand nine hundred and ninety-one】
catchError Use notes
I always thought source observable Even after an error , I will also follow pipe Inside operator After the sequential processing of catchError, It's not , Is to skip the previous operator Handle , Directly be catchError operator catch live . Examples are as follows :
const example$ = new Subject<number>();
// When source observable An error occurred ,pipe Inside operator They're not leaving , Go directly catachError
example$.pipe(
map(x => {
console.log(x); // When source observable After an error , This sentence will not execute
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);
The results are as follows :
map 1
value= 2
catchError 2
had error: excute 2 failed
边栏推荐
猜你喜欢

核酸检测机器人

Music retrieval system based on SSH

Carbon reduction in the construction industry is by no means a fresh idea experts suggest strengthening the transformation of rural buildings

More durable game real wireless headset with large battery and long endurance. Hero G1 can use it

更耐用的游戏真无线耳机,电池超大续航持久,英雄G1上手

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

子网划分不会?瑞哥带你深入理解IP地址,手把手教你子网划分!

基于分布式数据库本身的定时备份方法

No subnet partition? Rego will help you understand IP addresses and teach you how to divide subnets!

C#大作业——学生信息管理系统
随机推荐
Sword finger position operation
【黄啊码】PHP7为什么比PHP5快两倍?
Flink CDC + Hudi 海量数据入湖在顺丰的实践
js通过递归实现树形数据操作
uniapp实现授权登录
Kubernetes setting master schedulable and non schedulable
杰理之BLE功耗异常【篇】
LocalDateTime与String日期互相转换
杰理之BLE OTA 升级需要关闭不必要的外设【篇】
cocoslua在vs2013的调试方法
Initial experience of a one-stop solution for general target detection and recognition based on shengteng AI heterogeneous computing architecture cann
企评家分不同维度解析:湖南长城科技信息有限公司企业成长性
数商云商业服务业SaaS管理系统:实现高效业务协作,助力企业完善数字化转型之路
PV operation daily question - ticket sales
Modstartcms enterprise content site building system (supporting laravel9) v4.1.0
Android 13 针对 Intent Filters 安全的再升级
Niuke Mianjing 02
Transfer of 30% equity of Zhuhai Gaoyuan Electric Energy Technology Co., Ltd., shared by tamigou
基于昇腾AI异构计算架构CANN的通用目标检测与识别一站式方案初体验
【SignalR全套系列】之在.Net6中实现SignalR分组通信