You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -242,13 +256,56 @@ class ExpiredTokenRetryPolicy extends RetryPolicy {
242
256
243
257
You can also set the maximum amount of retry attempts with `maxRetryAttempts` property or override the `shouldAttemptRetryOnException` if you want to retry the request after it failed with an exception.
244
258
259
+
### RetryPolicy Interface
260
+
261
+
The `RetryPolicy` abstract class provides the following methods that you can override:
262
+
263
+
-**`shouldAttemptRetryOnException(Exception reason, BaseRequest request)`**: Called when an exception occurs during the request. Return `true` to retry, `false` to fail immediately.
264
+
-**`shouldAttemptRetryOnResponse(BaseResponse response)`**: Called after receiving a response. Return `true` to retry, `false` to accept the response.
265
+
-**`maxRetryAttempts`**: The maximum number of retry attempts (default: 1).
266
+
-**`delayRetryAttemptOnException({required int retryAttempt})`**: Delay before retrying after an exception (default: no delay).
267
+
-**`delayRetryAttemptOnResponse({required int retryAttempt})`**: Delay before retrying after a response (default: no delay).
268
+
269
+
### Using Retry Policies
270
+
271
+
To use a retry policy, pass it to the `InterceptedClient` or `InterceptedHttp`:
272
+
273
+
```dart
274
+
final client = InterceptedClient.build(
275
+
interceptors: [WeatherApiInterceptor()],
276
+
retryPolicy: ExpiredTokenRetryPolicy(),
277
+
);
278
+
```
279
+
245
280
Sometimes it is helpful to have a cool-down phase between multiple requests. This delay could for example also differ between the first and the second retry attempt as shown in the following example.
246
281
247
282
```dart
248
283
class ExpiredTokenRetryPolicy extends RetryPolicy {
0 commit comments