Created
July 14, 2017 06:53
-
-
Save qwtel/8956a5d7e995b3f41ae48a086bf2818e to your computer and use it in GitHub Desktop.
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
function filterWithAll(p$, ...others) { | |
if (process.env.DEBUG && !p$) throw Error(); | |
else if (others.length === 0) { | |
return this::withLatestFrom(p$)::filter(([, p]) => p)::map(([x]) => x); | |
} else { | |
return this::withLatestFrom(p$, ...others) | |
::filter(([, ...ps]) => ps.every(p => p)) | |
::map(([x]) => x); | |
} | |
} | |
function pauseableAll(pauser$, ...others) { | |
if (process.env.DEBUG && !pauser$) throw Error(); | |
if (others.length === 0) { | |
return pauser$::switchMap(paused => (paused ? Observable::never() : this)); | |
} else { | |
return pauser$::combineLatest(...others) | |
::switchMap(states => (states.some(s => s) ? Observable.never() : this)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment