Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active February 24, 2020 11:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cartant/1f596545d8d4b32df627ed2e8b99cc37 to your computer and use it in GitHub Desktop.
Save cartant/1f596545d8d4b32df627ed2e8b99cc37 to your computer and use it in GitHub Desktop.
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