Can you take Rx. There is such a thing as a BehaviorSubject
. All new subscribers will get the value from the "cache". When data is updated, all subscribers will receive them.
The only problem is that BehaviorSubject needs to be initialized with some initial data.
But also the Rx is the so-called "cold" Observable. There's a chain of calculations/actions will not be called until no subscribers. Ie, it's the laziness that we need. And most likely, there is a way to do lazy evaluation and the cache using Rx, I just don't know so well this libw. But Google should know.