@colisweb/rescript-toolkit 2.54.2 → 2.54.3
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
|
@@ -4,29 +4,25 @@ module type Config = {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
module Make = (Config: Config) => {
|
|
7
|
-
let key: Config.Request.argument =>
|
|
7
|
+
let key: Config.Request.argument => Swr.SwrKey.t = (arr)=> Config.key(arr)->Js.Array2.joinWith("--")->Swr.SwrKey.make
|
|
8
8
|
|
|
9
9
|
let use = (
|
|
10
10
|
~options: option<Swr.fetcherOptions>=?,
|
|
11
|
-
|
|
11
|
+
argument: option<Config.Request.argument>,
|
|
12
12
|
): Toolkit__Hooks.fetcher<Config.Request.response> =>
|
|
13
13
|
Toolkit__Hooks.useFetcher(
|
|
14
14
|
~options?,
|
|
15
|
-
|
|
15
|
+
argument->Option.map(key),
|
|
16
16
|
() => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Config.Request.exec(key)->Promise.Js.fromResult
|
|
17
|
+
Config.Request.exec(argument->Option.getExn)->Promise.Js.fromResult
|
|
20
18
|
},
|
|
21
19
|
)
|
|
22
20
|
|
|
23
21
|
let useOptional = (
|
|
24
22
|
~options: option<Swr.fetcherOptions>=?,
|
|
25
|
-
|
|
23
|
+
argument: option<Config.Request.argument>,
|
|
26
24
|
): Toolkit__Hooks.fetcher<option<Config.Request.response>> =>
|
|
27
|
-
Toolkit__Hooks.useOptionalFetcher(~options?,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Config.Request.exec(key)->Promise.Js.fromResult
|
|
25
|
+
Toolkit__Hooks.useOptionalFetcher(~options?, argument->Option.map(key), () => {
|
|
26
|
+
Config.Request.exec(argument->Option.getExn)->Promise.Js.fromResult
|
|
31
27
|
})
|
|
32
28
|
}
|
package/src/vendors/Swr.res
CHANGED
|
@@ -46,25 +46,27 @@ type fetcher<'data> = {
|
|
|
46
46
|
mutate: (. unit) => Js.Promise.t<bool>,
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
module SwrKey = Toolkit__Identifier.MakeString()
|
|
50
|
+
|
|
49
51
|
@module("swr")
|
|
50
|
-
external useSwr: (
|
|
52
|
+
external useSwr: (option<SwrKey.t>, 'fn, 'fetcherOptions) => fetcher<'data> = "default"
|
|
51
53
|
|
|
52
54
|
@module("swr")
|
|
53
|
-
external useSwrOptional: (
|
|
55
|
+
external useSwrOptional: (option<SwrKey.t>, 'fn, 'fetcherOptions) => fetcher<option<'data>> = "default"
|
|
54
56
|
|
|
55
57
|
type cache
|
|
56
58
|
@module("swr") external cache: cache = "cache"
|
|
57
59
|
@send external clear: cache => unit = "clear"
|
|
58
|
-
@send external delete: (cache,
|
|
60
|
+
@send external delete: (cache, option<SwrKey.t>) => unit = "delete"
|
|
59
61
|
|
|
60
62
|
module SwrConfig = {
|
|
61
63
|
type t
|
|
62
64
|
|
|
63
65
|
@send
|
|
64
|
-
external mutate0: (t,
|
|
66
|
+
external mutate0: (t, SwrKey.t) => unit = "mutate"
|
|
65
67
|
|
|
66
68
|
@send
|
|
67
|
-
external mutate: (t,
|
|
69
|
+
external mutate: (t, SwrKey.t, 'data, bool) => unit = "mutate"
|
|
68
70
|
|
|
69
71
|
@module("swr") @react.component
|
|
70
72
|
external make: (~value: fetcherOptions=?, ~children: React.element) => React.element = "SWRConfig"
|