Created
January 28, 2020 12:43
-
-
Save kelvearagao/1a67e127e0277c3563a0328ab5d42cd5 to your computer and use it in GitHub Desktop.
RxJs: redux-observable and buffer debounce
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 startWsEpic = action$ => action$.pipe( | |
ofType(START_WS), | |
mergeMap(action => { | |
const source$ = ws(action.payload).pipe(share()) | |
return source$.pipe( | |
takeUntil(action$.ofType(STOP_WS)), | |
buffer(source$.pipe(debounceTime(100))), | |
map(data => updateData(data)), | |
catchError(() => of(updateDataError())) | |
) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment