- Cold Observables are observables where data is produced inside the Observable. It can be treated as a unicast.
const obs$ = new Obserable((observer) => {
observer.next(Math.random());
});
obs$.subscribe((data) => console.log(data)); // prints different value
obs$.subscribe((data) => console.log(data)); // prints different value
- Hot Observables are observables where data is produced outside the Observable. It can be treated as a multicast.
const data = 5;
const obs$ = new Obserable((observer) => {
observer.next(data);
});
obs$.subscribe((data) => console.log(data)); // prints 5
obs$.subscribe((data) => console.log(data)); // prints 5
Related