@colisweb/rescript-toolkit 5.16.3 → 5.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/request/Request.res +33 -1
package/package.json
CHANGED
package/src/request/Request.res
CHANGED
|
@@ -22,7 +22,6 @@ type requestConfig<'apiError, 'response> = {
|
|
|
22
22
|
~response_decode,
|
|
23
23
|
) => {
|
|
24
24
|
// TODO :
|
|
25
|
-
// - parseJson
|
|
26
25
|
// - abort controller signal
|
|
27
26
|
|
|
28
27
|
(instance->Ky.Instance.asCallable)(path, ~options=requestOptions)
|
|
@@ -251,3 +250,36 @@ let decodeRawResponse = (result: result<Js.Json.t, Ky.error>, decoder): result<
|
|
|
251
250
|
->Result.mapError(err => Unknown(err))
|
|
252
251
|
->Result.flatMap(json => json->decoder->Result.mapError(err => DecodeError(err)))
|
|
253
252
|
}
|
|
253
|
+
|
|
254
|
+
let mutate = (
|
|
255
|
+
type argument response err,
|
|
256
|
+
swrConfig: Swr.SwrConfig.t,
|
|
257
|
+
config: module(Config with
|
|
258
|
+
type argument = argument
|
|
259
|
+
and type response = response
|
|
260
|
+
and type error = err
|
|
261
|
+
),
|
|
262
|
+
argument: argument,
|
|
263
|
+
) => {
|
|
264
|
+
let module(Config) = config
|
|
265
|
+
swrConfig->Swr.SwrConfig.mutateByKey(Array(Config.config(argument).key->Option.getUnsafe))
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let mutateWithParams = (
|
|
269
|
+
type argument response err,
|
|
270
|
+
swrConfig: Swr.SwrConfig.t,
|
|
271
|
+
config: module(Config with
|
|
272
|
+
type argument = argument
|
|
273
|
+
and type response = response
|
|
274
|
+
and type error = err
|
|
275
|
+
),
|
|
276
|
+
argument: argument,
|
|
277
|
+
params,
|
|
278
|
+
) => {
|
|
279
|
+
let module(Config) = config
|
|
280
|
+
swrConfig->Swr.SwrConfig.mutateByKeyWithParams(
|
|
281
|
+
Array(Config.config(argument).key->Option.getUnsafe),
|
|
282
|
+
params,
|
|
283
|
+
false,
|
|
284
|
+
)
|
|
285
|
+
}
|