rxjs 5 中的发布和多播运算符有什么区别?

What's the difference between publish and multicast operator in rxjs 5?

我正在阅读 rxjs 手册,我对多播和发布运算符之间的区别有点困惑。他们看起来很像。

他们确实很像,而且他们的来历更是让人摸不着头脑。

简单来说,publish是多播的一个特例。发布总是创建一个新主题(然后几乎使用多播),而多播使用提供的主题作为参数。

阅读http://reactivex.io/rxjs/manual/overview.html时我也有同样的疑问。因此,为了清楚起见,.publish() 只是 shorthand for .multicast(new Rx.Subject())(并且 publishBehaviorpublishLastpublishReplay 相似但实例化 BehaviorSubjectAsyncSubjectReplaySubject