Created
December 12, 2018 04:46
-
-
Save caroso1222/a45dfd5959298abeaa2a7f4d9ffb4df3 to your computer and use it in GitHub Desktop.
rxjs-pausable-example
This file contains hidden or 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
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