@colisweb/rescript-toolkit 5.20.3 → 5.21.0
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 +2 -2
- package/src/request/Request.res +45 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"lenses-ppx": "6.1.10",
|
|
54
54
|
"list-selectors": "2.0.1",
|
|
55
55
|
"lodash": "4.17.21",
|
|
56
|
-
"msw": "2.
|
|
56
|
+
"msw": "2.6.4",
|
|
57
57
|
"postcss": "8.4.47",
|
|
58
58
|
"postcss-preset-env": "8.0.1",
|
|
59
59
|
"prismjs": "1.29.0",
|
package/src/request/Request.res
CHANGED
|
@@ -284,3 +284,48 @@ let mutateWithParams = (
|
|
|
284
284
|
revalidate,
|
|
285
285
|
)
|
|
286
286
|
}
|
|
287
|
+
|
|
288
|
+
module FetchAndRender = {
|
|
289
|
+
@react.component
|
|
290
|
+
let make = (
|
|
291
|
+
type argument response err,
|
|
292
|
+
~config: module(Config with
|
|
293
|
+
type argument = argument
|
|
294
|
+
and type response = response
|
|
295
|
+
and type error = err
|
|
296
|
+
),
|
|
297
|
+
~argument,
|
|
298
|
+
~children,
|
|
299
|
+
) => {
|
|
300
|
+
let (data, _, _) = useFetcher(config, Some(argument))
|
|
301
|
+
|
|
302
|
+
children(data)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
module FetchAndRenderWithSuspense = {
|
|
307
|
+
@react.component
|
|
308
|
+
let make = (
|
|
309
|
+
type argument response err,
|
|
310
|
+
~config: module(Config with
|
|
311
|
+
type argument = argument
|
|
312
|
+
and type response = response
|
|
313
|
+
and type error = err
|
|
314
|
+
),
|
|
315
|
+
~argument,
|
|
316
|
+
~children,
|
|
317
|
+
~fallback=?,
|
|
318
|
+
~fallbackRender,
|
|
319
|
+
) => {
|
|
320
|
+
<Toolkit.Ui.ErrorBoundary
|
|
321
|
+
fallbackRender={({error}) => {
|
|
322
|
+
let module(C) = config
|
|
323
|
+
let apiError: error<C.error> = error->Obj.magic
|
|
324
|
+
fallbackRender(apiError)
|
|
325
|
+
}}>
|
|
326
|
+
<React.Suspense fallback={fallback->Option.getWithDefault(<Toolkit.Ui.SpinnerFullScreen />)}>
|
|
327
|
+
<FetchAndRender config argument> {data => children(data)} </FetchAndRender>
|
|
328
|
+
</React.Suspense>
|
|
329
|
+
</Toolkit.Ui.ErrorBoundary>
|
|
330
|
+
}
|
|
331
|
+
}
|