Skip to content

Instantly share code, notes, and snippets.

@web2ls
Created August 18, 2019 14:16
Show Gist options
  • Select an option

  • Save web2ls/8532b83d9721243b45263bec56c4b802 to your computer and use it in GitHub Desktop.

Select an option

Save web2ls/8532b83d9721243b45263bec56c4b802 to your computer and use it in GitHub Desktop.
Cold Observable
import * as Rx from "rxjs";
const observable = Rx.Observable.create((observer) => {
observer.next(Math.random());
});
// subscription 1
observable.subscribe((data) => {
console.log(data); // 0.24957144215097515 (random number)
});
// subscription 2
observable.subscribe((data) => {
console.log(data); // 0.004617340049055896 (random number)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment