@colisweb/rescript-toolkit 2.10.1 → 2.11.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.10.1",
3
+ "version": "2.11.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -0,0 +1,28 @@
1
+ module type Config = {
2
+ module Request: Toolkit__Request2.Config
3
+ let key: Request.argument => array<string>
4
+ }
5
+
6
+ module Make = (Config: Config) => {
7
+ let key: Config.Request.argument => array<string> = Config.key
8
+
9
+ let use = (
10
+ ~options: option<Swr.fetcherOptions>=?,
11
+ key: option<Config.Request.argument>,
12
+ ): Toolkit__Hooks.fetcher<Config.Request.response> =>
13
+ Toolkit__Hooks.useFetcher(~options?, key->Option.map(Config.key), () => {
14
+ let key = key->Option.getExn
15
+
16
+ Config.Request.exec(key)->Promise.Js.fromResult
17
+ })
18
+
19
+ let useOptional = (
20
+ ~options: option<Swr.fetcherOptions>=?,
21
+ key: option<Config.Request.argument>,
22
+ ): Toolkit__Hooks.fetcher<option<Config.Request.response>> =>
23
+ Toolkit__Hooks.useOptionalFetcher(~options?, key->Option.map(Config.key), () => {
24
+ let key = key->Option.getExn
25
+
26
+ Config.Request.exec(key)->Promise.Js.fromResult
27
+ })
28
+ }