-
-
Save huang47/55a3a6881a8038d02d98 to your computer and use it in GitHub Desktop.
suppress pause when end comes back to back
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
var Rx = require('rx'); | |
var pauses = new Rx.Subject(); | |
var ends = new Rx.Subject(); | |
pauses. | |
flatMap(function () { | |
return Rx.Observable.amb( | |
Rx.Observable.timer(1000). | |
map(function () { return true }), | |
ends.map(function () { return false }) | |
).take(1); | |
}). | |
filter(Boolean). | |
forEach( | |
console.log.bind(console, 'next'), | |
console.log.bind(console, 'error'), | |
console.log.bind(console, 'complete') | |
); | |
pauses.onNext('pause'); | |
setTimeout(function () { | |
ends.onNext('end'); | |
}, 1500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment