How to implement time expiry hot observable in RxJS (or general in Reactive Extensions)
问题 I'd like to implement Time Expiry cache with RxJs. Here is example of "normal" cache: //let this represents "heavy duty job" var data = Rx.Observable.return(Math.random() * 1000).delay(2000); //and we want to cache result var cachedData = new Rx.AsyncSubject(); data.subscribe(cachedData); cachedData.subscribe(function(data){ //after 2 seconds, result is here and data is cached //next subscribe returns immediately data cachedData.subscribe(function(data2){ /*this is "instant"*/ }); }); When