Skip to content

Instantly share code, notes, and snippets.

@kelvearagao
Created January 28, 2020 12:43
Show Gist options
  • Save kelvearagao/1a67e127e0277c3563a0328ab5d42cd5 to your computer and use it in GitHub Desktop.
Save kelvearagao/1a67e127e0277c3563a0328ab5d42cd5 to your computer and use it in GitHub Desktop.
RxJs: redux-observable and buffer debounce
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