Last active
December 12, 2019 09:59
-
-
Save Sawtaytoes/805f42219f8c7df65476d8ff5c895fc0 to your computer and use it in GitHub Desktop.
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 connectToServerEpic = ( | |
action$, | |
) => ( | |
action$ | |
.pipe( | |
ofType(CONNECT_TO_SERVER), | |
switchMap(({ | |
reconnectionTimeout, | |
// ... | |
}) => ( | |
action$ | |
.pipe( | |
ofType(RECONNECT_TO_SERVER), | |
takeUntil( | |
action$ | |
.pipe( | |
ofType(DISCONNECT_FROM_SERVER), | |
) | |
), | |
// ... | |
switchMap(( | |
webSocketConnection$, | |
) => ( | |
webSocketConnection$ | |
.pipe( | |
takeUntil( | |
action$ | |
.pipe( | |
ofType( | |
RECONNECT_TO_SERVER, | |
DISCONNECT_FROM_SERVER, | |
), | |
) | |
), | |
catchError(() => ( | |
timer( | |
reconnectionTimeout, | |
) | |
.pipe( | |
takeUntil( | |
action$ | |
.pipe( | |
ofType( | |
RECONNECT_TO_SERVER, | |
DISCONNECT_FROM_SERVER, | |
), | |
) | |
), | |
// ... | |
) | |
)), | |
// ... | |
)), | |
)), | |
) | |
)), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment