Last active
November 19, 2018 11:12
-
-
Save nlharri/03ba1aa6c8a0c294b4d35a0fb14ce8d9 to your computer and use it in GitHub Desktop.
RxJS Tutorial - Unsubscribe
This file contains 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
const { interval } = require('rxjs') | |
const { throttleTime } = require('rxjs/operators'); | |
// emit value every 500 millisecond (0.5 second) | |
const myObserver = interval(500); | |
const myThrottledObserver = myObserver.pipe(throttleTime(1000)); | |
const myDisposable = myThrottledObserver.subscribe(val => console.log(val)); | |
// unsubscribe after 10 seconds | |
setTimeout(() => { | |
myDisposable.unsubscribe(); | |
}, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment