当前位置:网站首页>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!completedIf 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! completedWhy 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边栏推荐
- 毕设-基于SSM大学生兼职平台系统
- Explain Bleu in machine translation task in detail
- Outsourcing for four years, abandoned
- Wechat applet full stack development practice Chapter 3 Introduction and use of APIs commonly used in wechat applet development -- 3.10 tabbar component (I) how to open and use the default tabbar comp
- 四、高性能 Go 语言发行版优化与落地实践 青训营笔记
- 一、Go知识查缺补漏+实战课程笔记 | 青训营笔记
- The currently released SKU (sales specification) information contains words that are suspected to have nothing to do with baby
- Docker compose start redis cluster
- $parent (get parent component) and $root (get root component)
- Detailed explanation of transform origin attribute
猜你喜欢

二、并发、测试笔记 青训营笔记

我理想的软件测试人员发展状态
![[2022 ACTF]web题目复现](/img/e4/ab9a1771489d751ee73a79f151d374.png)
[2022 ACTF]web题目复现

外包幹了三年,廢了...

1140_ SiCp learning notes_ Use Newton's method to solve the square root

SQLMAP使用教程(四)实战技巧三之绕过防火墙

抽丝剥茧C语言(高阶)指针进阶练习

Outlier detection technology of time series data

Stockage et pratique des données en langage C (haut niveau)

Bi she - college student part-time platform system based on SSM
随机推荐
弹性布局(一)
面试官:你都了解哪些开发模型?
深度学习花书+机器学习西瓜书电子版我找到了
三、高质量编程与性能调优实战 青训营笔记
身边35岁程序员如何建立起技术护城河?
[2022 ACTF]web题目复现
Outsourcing for four years, abandoned
Non empty verification of collection in SQL
Freeswitch dials extension number source code tracking
电商常规问题part1
SQLMAP使用教程(四)实战技巧三之绕过防火墙
[2022 CISCN]初赛 web题目复现
Outsourcing for three years, abandoned
JS small exercise
Music | cat and mouse -- classic not only plot
基于Flask搭建个人网站
Leetcode-226. Invert Binary Tree
MobaXterm
修改Jupyter Notebook文件路径
C language (high-level) data storage + Practice