Q:

Angular RxJS - fail to make cold observable hot

Code:
const cold = new Observable((observer: Observer<any>) => {
  observer.next(Math.random());
});

const hot = cold.pipe(share());
hot.subscribe(a =>  console.log('a: ' + a));
hot.subscribe(b =>  console.log('b: ' + b));

}
Expected result - a and b has the same value:
// a: 0.17919353301075858
// b: 0.17919353301075858
Actual result - only get value of a in the browser console:
// a: 0.07958207844185083
Any idea? 

A:

You could try shareReplay(1) to replay last value
https://www.learnrxjs.io/learn-rxjs/operators/multicasting/sharereplay
Also, a good article: https://itnext.io/the-magic-of-rxjs-sharing-operators-and-their-differences-3a03d699d255

