RxJs Subject.subscribe method not working as expected

不问归期 提交于 2019-11-29 15:35:07
martin

Be aware of using Subject.create().

This is not the same as new Subject() and absolutely most of the time you want to use just new Subject() instead of Subject.create(). With Subject.create() you're creating an instance of AnonymousSubject which never subscribes itself and therefore the flatMap() operator throws an error when trying to subscribe AnonymousSubject to another AnonymousSubject.

See my answer to a similar question: Subjects created with Subject.create can't unsubscribe.

I just changed Subject.create() to new Subject() and it's probably working.

See your updated demo: https://plnkr.co/edit/6M1lPLZA16vwQsVAjNzc?p=preview

Although, I don't know what's that demo supposed to do so I can't tell whether it's working correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!