Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created February 21, 2020 21:57
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 OliverJAsh/c02c9227b35627e833d3caf736a6b0be to your computer and use it in GitHub Desktop.
Save OliverJAsh/c02c9227b35627e833d3caf736a6b0be to your computer and use it in GitHub Desktop.
export const delayUntil = <T>(
signal$: RxJS.Observable<unknown>,
): RxJS.OperatorFunction<T, T> => ob$ =>
ob$.pipe(
RxJSOperators.publishReplay(undefined, undefined, publishedOb$ =>
RxJS.concat(
signal$.pipe(RxJSOperators.first(), RxJSOperators.mergeMapTo(RxJS.EMPTY)),
publishedOb$,
),
),
);
/**
* Waits for a minimum time `ms` before emitting `ob$`.
*/
export const waitMinimumOf = <T>(ms: number): RxJS.OperatorFunction<T, T> => ob$ =>
ob$.pipe(delayUntil(RxJS.timer(ms)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment