Sawtaytoes
11/6/2018 - 8:46 PM

Continuing from Erroneous AJAX Calls

WIP

const { interval, of, throwError } = Rx;
const { catchError, concat, endWith, switchMap, take } = RxOperators;

interval(1000)
.pipe(
  take(4),
  switchMap(value => (
    value === 2
    ? (
      throwError('error')
      .pipe(
        catchError(() => of('caughtError')),
      )
    )
    : of(value)
  )),
  concat(of('concatted')),
  endWith('hi'),
)
const { interval, of, throwError } = Rx;
const { catchError, concat, endWith, ignoreElements, switchMap, take } = RxOperators;

interval(1000)
.pipe(
  take(4),
  switchMap(value => (
    value === 2
    ? (
      throwError('error')
      .pipe(
        catchError(() => of('caughtError')),
        ignoreElements(),
      )
    )
    : of(value)
  )),
  concat(of('concatted')),
  endWith('hi'),
)