Skip to content

Instantly share code, notes, and snippets.

@Sawtaytoes
Last active December 12, 2019 09:59
Show Gist options
  • Save Sawtaytoes/805f42219f8c7df65476d8ff5c895fc0 to your computer and use it in GitHub Desktop.
Save Sawtaytoes/805f42219f8c7df65476d8ff5c895fc0 to your computer and use it in GitHub Desktop.
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