Skip to content

Commit c5fd54c

Browse files
committed
feat(dart): add option to pass custom JsonConverter to ChopperRequester constructor
1 parent d812167 commit c5fd54c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

clients/algoliasearch-client-dart/packages/chopper_requester/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ final requester = ChopperRequester({
8080
/// The Chopper Interceptors to use for modifying the request
8181
Iterable<Interceptor>? interceptors,
8282
/// The HTTP client to use for sending requests
83-
Client? client
83+
Client? client,
84+
/// A custom JSON converter to use for serializing and deserializing JSON
85+
JsonConverter? converter,
8486
});
8587
```
8688

@@ -98,11 +100,11 @@ final requester = ChopperRequester(
98100
);
99101
```
100102

101-
### Custom Interceptors
103+
#### Custom Interceptors
102104

103105
For interceptors please see the [Chopper documentation](https://hadrien-lejard.gitbook.io/chopper/interceptors).
104106

105-
### Custom Clients
107+
#### Custom Clients
106108

107109
Via the `client` option users can use platform specific HTTP clients such:
108110
- [cronet_http](https://pub.dev/packages/cronet_http) on Android
@@ -130,6 +132,11 @@ Via the `client` option users can use platform specific HTTP clients such:
130132
),
131133
);
132134
```
135+
136+
#### Parsing JSON in the background using Isolates
137+
138+
Parsing JSON in the background is a good idea if you don't want to block the main thread.
139+
Please see the [Chopper documentation](https://hadrien-lejard.gitbook.io/chopper/faq#decoding-json-using-isolates) on Decoding JSON using thread pool workers.
133140

134141
## License
135142

clients/algoliasearch-client-dart/packages/chopper_requester/lib/src/chopper_requester.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class ChopperRequester implements Requester {
2626
Logger? logger,
2727
Iterable<Interceptor>? interceptors,
2828
http.Client? client,
29+
JsonConverter? converter,
2930
}) : _client = ChopperClient(
3031
client: client,
31-
converter: JsonConverter(),
32+
converter: converter ?? JsonConverter(),
3233
interceptors: [
3334
AuthInterceptor(
3435
appId: appId,

0 commit comments

Comments
 (0)