Subject vs AnonymousSubject

别等时光非礼了梦想. 提交于 2019-12-01 20:27:39

问题


What's the difference between Subject and AnonymousSubject in RxJS 5? I've searched the internet but didn't find any info about AnonymousSubject.

I've found an example on the web

Subject.create(observer, observable);

Looking into rxjs source code I saw that this creates and AnonymousSubject. Can you also come up with an example when is good to use AnonymousSubject?


回答1:


The AnonymousSubject doesn't subscribe itself to the source Observable. It just connects the source and destination.

I don't know what a typical use-case for AnonymousSubject looks like but it's used inside Subject.lift().

Also see: RxJs Subject.subscribe method not working as expected



来源:https://stackoverflow.com/questions/42148463/subject-vs-anonymoussubject

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