Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active February 13, 2019 03:08
Show Gist options
  • Select an option

  • Save cartant/b8bda639687e56f062f1a6ee96e82678 to your computer and use it in GitHub Desktop.

Select an option

Save cartant/b8bda639687e56f062f1a6ee96e82678 to your computer and use it in GitHub Desktop.
import { timer } from "rxjs";
import { shareReplay, takeUntil } from "rxjs/operators";
import { log } from "./log";
const source = log(timer(100), "source");
const shared = log(source.pipe(shareReplay(1)), "shared");
shared.pipe(
takeUntil(timer(50))
).subscribe(
value => console.log(`first received: ${value}`)
);
setTimeout(() => shared.subscribe(
value => console.log(`second received: ${value}`)
), 150);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment