Created
July 22, 2019 11:32
-
-
Save praveen001/a8b605a873f0d24fe1d90190f8077f39 to your computer and use it in GitHub Desktop.
Redux Observable WebSocket
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
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