Skip to content

Instantly share code, notes, and snippets.

@noxan
Created March 7, 2016 16:05
Show Gist options
  • Save noxan/539df2219482a39fab60 to your computer and use it in GitHub Desktop.
Save noxan/539df2219482a39fab60 to your computer and use it in GitHub Desktop.
const source = Rx.Observable.interval(1000);
const startDate = moment().add(1, 'minute');
const stream = Rx.Observable.merge(
Rx.Observable.of(undefined),
Rx.Observable.interval(10000)
).map(i => startDate);
Rx.Observable
.combineLatest(source, stream)
.map(([counter, value]) => {
return moment(value).diff(moment());
})
.distinctUntilChanged()
.filter(value => value > 0)
.subscribe(value => {
console.log(moment.utc(value).format('HH:mm:ss'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment