setRetryPolicy method

BuildRequest<T> setRetryPolicy(
  1. RetryPolicy policy
)

设置高级重试策略(支持指数退避、抖动等)

使用此方法后,setRetryCount 设置的值将被忽略。

RxNet.get()
  .setPath("/api/data")
  .setRetryPolicy(RetryPolicy.exponentialBackoff(
    maxRetries: 3,
    baseInterval: Duration(seconds: 1),
  ))
  .request();

Implementation

BuildRequest<T> setRetryPolicy(RetryPolicy policy) {
  _retryPolicy = policy;
  _retryCount = policy.maxRetries;
  return this;
}