Skip to content

Instantly share code, notes, and snippets.

@caroso1222
Created December 12, 2018 04:46
Show Gist options
  • Save caroso1222/a45dfd5959298abeaa2a7f4d9ffb4df3 to your computer and use it in GitHub Desktop.
Save caroso1222/a45dfd5959298abeaa2a7f4d9ffb4df3 to your computer and use it in GitHub Desktop.
rxjs-pausable-example
import { pausable, PausableObservable } from 'rxjs-pausable';
const source = interval(1000).pipe(
map(x => `Hello ${x}!`),
pauseable()
) as PausableObservable<string>;
source.subscribe(console.log);
setTimeout(() => source.pause(), 5000)
/**
* Output:
* Hello 0!
* Hello 1!
* Hello 2!
* Hello 3!
* Hello 4!
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment