When to multicast
Multicasting is helpful in preventing redundant work being done by multiple Observers and instead makes all Observers subscribe to a single stream, at least to the point where they have operations in common. You may do this to increase performance, reducing memory and CPU usage, or simply because your business logic requires pushing the same emissions to all Observers.
Data-driven cold Observables should only be multicast when you are doing so for performance reasons and have multiple Observers receiving the same data simultaneously. Remember that multicasting creates hot ConnectableObservables, and you have to be careful and time the connect() call so data is not missed by Observers. Typically in your API, keep your cold ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access