当前位置:网站首页>Rxjs - observable doesn't complete when an error occurs - rxjs - observable doesn't complete when an error occurs
Rxjs - observable doesn't complete when an error occurs - rxjs - observable doesn't complete when an error occurs
2022-07-07 07:34:00 【fyin1314】
problem :
When I create an observable from scratch, and have the observer error, then complete, the done part of the subscription never is invoked. When I create one from scratch observable And there are observer errors , Then when finished , The completed part of the subscription will never be called .
var observer = Rx.Observable.create(function(observer){ observer.onError(new Error('no!')); observer.onCompleted();})observer.subscribe( function(x) { console.log('succeeded with ' + x ) }, function(x) { console.log('errored with ' + x ) }, function() { console.log('completed') })
The output is: The output is :
errored with Error: no!
I'd expect it to be: I hope it is :
errored with Error: no!completed
If I change the code to invoke onNext instead of onError, the observable properly completes: If I change the code to call onNext instead of onError, be observable Will be completed correctly :
var observer = Rx.Observable.create(function(observer){ observer.onNext('Hi!'); observer.onCompleted();})observer.subscribe( function(x) { console.log('succeeded with ' + x ) }, function(x) { console.log('errored with ' + x ) }, function() { console.log('completed') })
I get the expected output: I get the expected output :
succeeded with Hi! completed
Why does it not complete when an error has occured? Why did it not complete when an error occurred ?
Solution :
Reference resources : https://stackoom.com/en/question/2Hkkh边栏推荐
- The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
- 虚拟机的作用
- My ideal software tester development status
- 抽絲剝繭C語言(高階)數據的儲存+練習
- Cloud backup project
- 修改Jupyter Notebook文件路径
- Readonly read only
- Hidden Markov model (HMM) learning notes
- 1141_ SiCp learning notes_ Functions abstracted as black boxes
- js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
猜你喜欢
07_ Handout on the essence and practical skills of text measurement and geometric transformation
Abnova membrane protein lipoprotein technology and category display
mips uclibc 交叉编译ffmpeg,支持 G711A 编解码
Introduction to abnova's in vitro mRNA transcription workflow and capping method
[2022 CISCN]初赛 web题目复现
How to reduce inventory with high concurrency on the Internet
Robot technology innovation and practice old version outline
[ANSYS] learning experience of APDL finite element analysis
3、 High quality programming and performance tuning practical youth training camp notes
Make a bat file for cleaning system garbage
随机推荐
我理想的软件测试人员发展状态
Fast quantitative, abbkine protein quantitative kit BCA method is coming!
Convolutional neural network -- understanding of pooling
MySQL service is missing from computer service
Cloud backup project
Interviewer: what development models do you know?
身边35岁程序员如何建立起技术护城河?
../ And/
[Linux] process control and parent-child processes
2、 Concurrent and test notes youth training camp notes
BGP experiment (1)
Composition API premise
三、高质量编程与性能调优实战 青训营笔记
Flutter riverpod is comprehensively and deeply analyzed. Why is it officially recommended?
虚拟机的作用
外包干了三年,废了...
Flexible layout (I)
一、Go知识查缺补漏+实战课程笔记 | 青训营笔记
js小练习----分时提醒问候、表单密码显示隐藏效果、文本框焦点事件、关闭广告
Summary of customer value model (RFM) technology for data analysis