Created
February 19, 2020 15:05
-
-
Save ArtemRomanovsky/6934f442a9da7ae280d796fd1100bdd4 to your computer and use it in GitHub Desktop.
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
const observable = Rx.Observable.interval(1000).take(5); | |
const observerA = {...}; | |
const observerB = {...}; | |
const hybrid = { | |
observers: [], | |
subscribe: (obs) => { | |
this.observers.push(obs); | |
} | |
next: (v) => { | |
this.observers.forEach((o) => { | |
o.next(v); | |
}) | |
} | |
} | |
observable.subscribe(hybrid); | |
hybrid.subscribe(observerA); // first execution | |
setTimeout(() => { | |
hybrid.subscribe(observerB); // the same execution | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment