add option to use cancellation token in ChopperClient #645
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes significant changes to the
chopper
package to add support for request cancellation using cancellation tokens. The changes involve updating various parts of the codebase to integrate the newcancellation_token_http
package and modifying existing methods to support cancellation functionality.Integration of cancellation tokens:
chopper/lib/src/base.dart
: Added a_cancellationToken
field and updated theChopperClient
constructor to accept an optionalcancellationToken
. Modified theexecute
method to handle cancellation and added acancelRequests
method to cancel ongoing requests. [1] [2] [3] [4] [5] [6]chopper/lib/src/chain/call.dart
: Updated theexecute
method to accept an optionalcancellationToken
parameter and pass it to theHttpCallInterceptor
. [1] [2] [3]Updates to interceptors:
chopper/lib/src/interceptors/http_call_interceptor.dart
: Modified theHttpCallInterceptor
to accept an optionalcancellationToken
and use it when making HTTP calls. [1] [2] [3]Example and test updates:
chopper/example/main.dart
: Added an example of using theCancellationToken
to cancel a request after a delay. [1] [2]chopper/test/*
: Updated tests to use thecancellation_token_http
package instead of thehttp
package. [1] [2] [3] [4] [5] [6] [7]Dependency updates:
chopper/pubspec.yaml
: Replaced thehttp
dependency withcancellation_token_http
.