Created
March 7, 2016 16:05
-
-
Save noxan/539df2219482a39fab60 to your computer and use it in GitHub Desktop.
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 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