Skip to content

Instantly share code, notes, and snippets.

@CharlieGreenman
Created November 11, 2019 10:49
Show Gist options
  • Select an option

  • Save CharlieGreenman/59801cba4edd024ed752c126cc3450e4 to your computer and use it in GitHub Desktop.

Select an option

Save CharlieGreenman/59801cba4edd024ed752c126cc3450e4 to your computer and use it in GitHub Desktop.
Hot Observable with two subscribers
import { Subject } from 'rxjs';
const random = Math.random();
const randomVal$ = new Subject().next(random);
// Subscribe to run the combined functions
randomVals$.subscribe(x => console.log(x));
// 0.8771441274333971 (random number)
randomVals$.subscribe(x => console.log(x));
// 0.8771441274333971 (random number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment