Created
November 9, 2015 11:00
-
-
Save Willmo36/d911ab45d8f0dcf5adff to your computer and use it in GitHub Desktop.
countdown with rx
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
const now = moment(); | |
const end = now.clone().add(2, 'minutes'); | |
const diff = (end - now) / 1000; | |
const tick$ = Rx.Observable.timer(0,1000) | |
.scan((acc) => { | |
return acc - 1; | |
}, diff) | |
.take(diff); | |
tick$.subscribe((v) => console.log(v)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment