主题vs AnonymousSubject [英] Subject vs AnonymousSubject
问题描述
RxJS 5 中主题
和 AnonymousSubject
之间的区别是什么?
我在互联网上搜索但没有找到任何关于 AnonymousSubject
的信息。
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);
查看rxjs源代码我看到这创建了 AnonymousSubject
。
你能想出一个好用的例子 AnonymousSubject
?
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
?
推荐答案
AnonymousSubject
不会订阅源Observable。它只是连接来源
和目的地
。
The AnonymousSubject
doesn't subscribe itself to the source Observable. It just connects the source
and destination
.
我不知道 AnonymousSubject
的典型用例是什么样的,但它在 Subject.lift()
。
I don't know what a typical use-case for AnonymousSubject
looks like but it's used inside Subject.lift()
.
另见: RxJs Subject.subscribe方法无法按预期工作
这篇关于主题vs AnonymousSubject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!