RetryWhen

Returns an Observable that mirrors the source Observable with the exception of an error. If the source Observable calls error, this method will emit the Throwable that caused the error to the Observable returned from notifier. If that Observable calls complete or error then this method will call complete or error on the child subscription. Otherwise, this method will resubscribe to the source Observable.

.pipe(
  catchError(err => {
    this.loader = false;
    console.log(err);
    if (err.status === 500 || err.status === 0) {
      this.isErrorFlag = true;
      this.messageResult = `There is a
        problem with our server connections, our engineers are already working on this problem.`;
    }
    return throwError(err);
  }),
  retryWhen(errors => errors.pipe(
    delayWhen(() => timer(300))
  ))
)

Last updated