shareReplay is the way!

Posted on Apr 12, 2021

I was working with an observable stream when I realized that for the particular scenario I was dealing with a ReplaySubject would be the best choice. There was the need to obtain all emitted values on subscribe (since there were multiple observers, attaching in different moments).

And that’s where shareReplay starts to shine! It’ll also help you in computing all effects once, even you subscribe to the same stream more than once. Look at this StackBlitz example to find out more!