Rxjs Retry with Delay function

前端 未结 10 2383
忘了有多久
忘了有多久 2020-11-30 06:32

I am trying to use retry with delay function, I expect function will call after 1000ms delay, but it doesnot, what can be error here? look at conso

10条回答
  •  伪装坚强ぢ
    2020-11-30 07:00

    I recently had this problem, and found that the accepted solution could be improved.

    Observable.pipe(
         retryWhen(errors => errors.pipe(
          delay(1000),
          take(10))),
        first(v => true),
        timeout(10000))
    

    What it essentially does is to retry as mentioned, but this finishes right away without adding any (erroneous) value using the 'first' operator.

    If it cannot find a value within the timeout timeframe, an error is raised.

提交回复
热议问题