I'm reading the rxjs manual, I'm a little confused about what's the difference between multicast and publish operators. They seem very similar.
Asked
Active
Viewed 2,048 times
2 Answers
21
I had the same question when reading http://reactivex.io/rxjs/manual/overview.html. So to make it clear, .publish()
is just shorthand for .multicast(new Rx.Subject())
(and publishBehavior
, publishLast
, and publishReplay
are similar but instantiate BehaviorSubject
, AsyncSubject
and ReplaySubject
respectively).

Ivan
- 1,317
- 13
- 23
5
They are indeed very similar, and they have a history that makes it even more confusing.
In simple terms, publish is a special case of multicast. publish always creates a new subject (and then pretty much uses multicast), whereas multicast uses the subject provided as an argument.

Ben Dadsetan
- 1,565
- 11
- 19