Sawtaytoes
10/16/2019 - 7:35 AM

pingEpic

const pingEpic = (
  action$,
) => (
  action$
  .pipe(
    ofType(CREATE_PING_LISTENER)
    mergeMap(({
      namespace,
    }) => (
      action$
      .pipe(
        ofType(PING),
        ofNamespace(namespace),
        takeUntil(
          action$
          .pipe(
            ofType(STOP_PING_LISTENER)
          )
        ),
        switchMap(() => (
          timer(1000)
        )),
        mapTo({ namespace }),
        map(pong),
    )),
  )
)