Skip to content

Instantly share code, notes, and snippets.

@praveen001
Created July 22, 2019 11:32
Show Gist options
  • Save praveen001/a8b605a873f0d24fe1d90190f8077f39 to your computer and use it in GitHub Desktop.
Save praveen001/a8b605a873f0d24fe1d90190f8077f39 to your computer and use it in GitHub Desktop.
Redux Observable WebSocket
const disconnectEpic = (action$, state$: StateObservable<IState>) =>
action$
.ofType(WebsocketActionTypes.DISCONNECT)
.mergeMap((action: IDisconnectFromWebsocketAction) => {
if (action.payload.retry) {
return of(connect(state$.value.config.webSocketURL)) // <-- reconnect
.delay(5000)
.startWith(disconnected());
}
onCloseSubject.complete();
webSocketSubject.complete();
return [disconnected()];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment