Skip to content

Instantly share code, notes, and snippets.

@Willmo36
Created November 9, 2015 11:00
Show Gist options
  • Save Willmo36/d911ab45d8f0dcf5adff to your computer and use it in GitHub Desktop.
Save Willmo36/d911ab45d8f0dcf5adff to your computer and use it in GitHub Desktop.
countdown with rx
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