Skip to content

Instantly share code, notes, and snippets.

@kruschid
Created April 19, 2023 19:00
Show Gist options
  • Save kruschid/5c0ebec82a2c8084cecdabf7fd6418e5 to your computer and use it in GitHub Desktop.
Save kruschid/5c0ebec82a2c8084cecdabf7fd6418e5 to your computer and use it in GitHub Desktop.
rxjs debounced buffer operator
export const debouncedBufferTime = <T extends object>(
time: number
) => (
observable: Observable<T>
): Observable<T[]> => {
const messageSubject = new Subject<1>();
const debouncedMessage$ = messageSubject.pipe(debounceTime(time));
return observable.pipe(
tap(() => messageSubject.next(1)),
buffer(debouncedMessage$),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment