0 votes
in Angular by
What is multicasting in Angular?

1 Answer

0 votes
by

Multicasting or Multi-casting is the practice of broadcasting to a list of multiple subscribers in a single execution.

Let's take a simple example to demonstrate the multi-casting feature:

  1. var source = Rx.Observable.from([123]);  
  2. var subject = new Rx.Subject();  
  3. var multicasted = source.multicast(subject);  
  4. // These are, under the hood, `subject.subscribe({...})`:  
  5. multicasted.subscribe({  
  6.   next: (v) => console.log('observerA: ' + v)  
  7. });  
  8. multicasted.subscribe({  
  9.   next: (v) => console.log('observerB: ' + v)  
  10. });  
...