Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh

OliverJAsh/foo.ts

Created Feb 21, 2020
Embed
What would you like to do?
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