Created
April 19, 2023 19:00
-
-
Save kruschid/5c0ebec82a2c8084cecdabf7fd6418e5 to your computer and use it in GitHub Desktop.
rxjs debounced buffer operator
This file contains 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
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