Skip to content

Instantly share code, notes, and snippets.

@huang47
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huang47/55a3a6881a8038d02d98 to your computer and use it in GitHub Desktop.
Save huang47/55a3a6881a8038d02d98 to your computer and use it in GitHub Desktop.
suppress pause when end comes back to back
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