Last active
February 24, 2020 11:28
-
-
Save cartant/1f596545d8d4b32df627ed2e8b99cc37 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
import { concat, NEVER, Observable, OperatorFunction } from "rxjs"; | |
import { buffer, mergeAll, publish, take } from "rxjs/operators"; | |
function delayUntil<T>(notifier: Observable<any>): OperatorFunction<T, T> { | |
return source => | |
source.pipe( | |
publish(published => | |
concat( | |
concat(published, NEVER).pipe(buffer(notifier), take(1), mergeAll()), | |
published | |
) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment