Last active
October 7, 2021 16:50
-
-
Save vitaly-t/4cd75c08640129ae736cb487b22f16a3 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
/** | |
* Drains the source observable till it completes, and then posts a new value-observable. | |
*/ | |
function drain<T>(value: T | Observable<T> | (() => T | Observable<T>)) { | |
const v = () => { | |
const a = typeof value === 'function' ? value.call(null) : value; | |
return a instanceof Observable ? a : of(a); | |
} | |
return s => defer(() => s.pipe(filter(_ => false), c => concat(c, v()))) as Observable<T>; | |
} | |
function startTimer() { | |
return drain(Date.now); | |
} | |
// SEE: https://stackoverflow.com/questions/69472548/remap-rxjs-observable-to-a-timer-start-without-stream-interruption |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment