Created
March 15, 2016 16:43
-
-
Save feliperohdee/9fd7cb44d24b1adf146c to your computer and use it in GitHub Desktop.
Observable cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cache = (source: Observable<any>) => { | |
let replay: ReplaySubject<any>; | |
return source | |
.multicast(() => { | |
if (!replay) { | |
replay = new ReplaySubject(2); | |
setTimeout(() => replay = null, 2500); | |
} | |
return replay; | |
}) | |
.refCount(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment