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,
),
)
),
// ...
)
)),
// ...
)),
)),
)
)),
)
)