@ic-reactor/react 3.12.4 → 3.13.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/README.md +410 -44
- package/dist/auth/auth-client-compat.d.ts +122 -0
- package/dist/auth/auth-client-compat.d.ts.map +1 -0
- package/dist/auth/auth-client-compat.js +162 -0
- package/dist/auth/auth-client-compat.js.map +1 -0
- package/dist/auth/authentication-manager.d.ts +287 -5
- package/dist/auth/authentication-manager.d.ts.map +1 -1
- package/dist/auth/authentication-manager.js +920 -150
- package/dist/auth/authentication-manager.js.map +1 -1
- package/dist/auth/createIdentityAttributeHooks.d.ts.map +1 -1
- package/dist/auth/createIdentityAttributeHooks.js +36 -20
- package/dist/auth/createIdentityAttributeHooks.js.map +1 -1
- package/dist/auth/identity-attributes-manager.d.ts +2 -1
- package/dist/auth/identity-attributes-manager.d.ts.map +1 -1
- package/dist/auth/identity-attributes-manager.js +90 -6
- package/dist/auth/identity-attributes-manager.js.map +1 -1
- package/dist/auth/identity-attributes.d.ts.map +1 -1
- package/dist/auth/identity-attributes.js +57 -0
- package/dist/auth/identity-attributes.js.map +1 -1
- package/dist/auth/local-ii-probe.d.ts +12 -1
- package/dist/auth/local-ii-probe.d.ts.map +1 -1
- package/dist/auth/local-ii-probe.js +22 -3
- package/dist/auth/local-ii-probe.js.map +1 -1
- package/dist/auth/types.d.ts +48 -5
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/createActorHooks.d.ts +9 -20
- package/dist/createActorHooks.d.ts.map +1 -1
- package/dist/createActorHooks.js.map +1 -1
- package/dist/createInfiniteQuery.d.ts +51 -10
- package/dist/createInfiniteQuery.d.ts.map +1 -1
- package/dist/createInfiniteQuery.js +39 -15
- package/dist/createInfiniteQuery.js.map +1 -1
- package/dist/createMutation.d.ts +4 -1
- package/dist/createMutation.d.ts.map +1 -1
- package/dist/createMutation.js +121 -84
- package/dist/createMutation.js.map +1 -1
- package/dist/createQuery.d.ts +35 -2
- package/dist/createQuery.d.ts.map +1 -1
- package/dist/createQuery.js +104 -17
- package/dist/createQuery.js.map +1 -1
- package/dist/createReactorProvider.d.ts +158 -0
- package/dist/createReactorProvider.d.ts.map +1 -0
- package/dist/createReactorProvider.js +256 -0
- package/dist/createReactorProvider.js.map +1 -0
- package/dist/createSuspenseInfiniteQuery.d.ts +16 -9
- package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/createSuspenseInfiniteQuery.js +59 -27
- package/dist/createSuspenseInfiniteQuery.js.map +1 -1
- package/dist/createSuspenseQuery.d.ts +23 -2
- package/dist/createSuspenseQuery.d.ts.map +1 -1
- package/dist/createSuspenseQuery.js +68 -21
- package/dist/createSuspenseQuery.js.map +1 -1
- package/dist/defineDisplayReactor.d.ts +43 -0
- package/dist/defineDisplayReactor.d.ts.map +1 -0
- package/dist/defineDisplayReactor.js +42 -0
- package/dist/defineDisplayReactor.js.map +1 -0
- package/dist/defineReactor.d.ts +46 -72
- package/dist/defineReactor.d.ts.map +1 -1
- package/dist/defineReactor.js +11 -176
- package/dist/defineReactor.js.map +1 -1
- package/dist/defineReactorShared.d.ts +84 -0
- package/dist/defineReactorShared.d.ts.map +1 -0
- package/dist/defineReactorShared.js +139 -0
- package/dist/defineReactorShared.js.map +1 -0
- package/dist/hooks/createAuthHooks.d.ts +9 -2
- package/dist/hooks/createAuthHooks.d.ts.map +1 -1
- package/dist/hooks/createAuthHooks.js +184 -24
- package/dist/hooks/createAuthHooks.js.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.d.ts +36 -8
- package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.js +54 -21
- package/dist/hooks/useActorInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorMethod.d.ts +37 -4
- package/dist/hooks/useActorMethod.d.ts.map +1 -1
- package/dist/hooks/useActorMethod.js +201 -57
- package/dist/hooks/useActorMethod.js.map +1 -1
- package/dist/hooks/useActorMutation.d.ts +15 -12
- package/dist/hooks/useActorMutation.d.ts.map +1 -1
- package/dist/hooks/useActorMutation.js +14 -13
- package/dist/hooks/useActorMutation.js.map +1 -1
- package/dist/hooks/useActorQuery.d.ts +17 -4
- package/dist/hooks/useActorQuery.d.ts.map +1 -1
- package/dist/hooks/useActorQuery.js +30 -9
- package/dist/hooks/useActorQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +17 -5
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js +37 -17
- package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.d.ts +2 -2
- package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.js +20 -9
- package/dist/hooks/useActorSuspenseQuery.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/ownedAuthentication.d.ts +52 -0
- package/dist/ownedAuthentication.d.ts.map +1 -0
- package/dist/ownedAuthentication.js +49 -0
- package/dist/ownedAuthentication.js.map +1 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +23 -0
- package/dist/server.js.map +1 -0
- package/dist/testing.d.ts +19 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +19 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +428 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +159 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +301 -1
- package/dist/utils.js.map +1 -1
- package/dist/validation.d.ts +12 -7
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +34 -15
- package/dist/validation.js.map +1 -1
- package/llms.txt +259 -33
- package/package.json +17 -5
- package/src/auth/auth-client-compat.ts +273 -0
- package/src/auth/authentication-manager.ts +918 -96
- package/src/auth/createIdentityAttributeHooks.ts +47 -21
- package/src/auth/identity-attributes-manager.ts +100 -5
- package/src/auth/identity-attributes.ts +75 -0
- package/src/auth/local-ii-probe.ts +29 -3
- package/src/auth/types.ts +49 -6
- package/src/createActorHooks.ts +50 -42
- package/src/createInfiniteQuery.ts +120 -28
- package/src/createMutation.ts +213 -132
- package/src/createQuery.ts +164 -32
- package/src/createReactorProvider.ts +365 -0
- package/src/createSuspenseInfiniteQuery.ts +93 -43
- package/src/createSuspenseQuery.ts +102 -32
- package/src/defineDisplayReactor.ts +62 -0
- package/src/defineReactor.ts +81 -263
- package/src/defineReactorShared.ts +268 -0
- package/src/hooks/createAuthHooks.ts +210 -28
- package/src/hooks/useActorInfiniteQuery.ts +156 -55
- package/src/hooks/useActorMethod.ts +295 -92
- package/src/hooks/useActorMutation.ts +42 -30
- package/src/hooks/useActorQuery.ts +43 -10
- package/src/hooks/useActorSuspenseInfiniteQuery.ts +110 -54
- package/src/hooks/useActorSuspenseQuery.ts +30 -15
- package/src/index.ts +8 -0
- package/src/ownedAuthentication.ts +81 -0
- package/src/server.ts +23 -0
- package/src/testing.ts +18 -0
- package/src/types.ts +492 -22
- package/src/utils.ts +387 -3
- package/src/validation.ts +43 -19
|
@@ -1,6 +1,28 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
import { useQuery, useMutation, } from "@tanstack/react-query";
|
|
3
|
-
import { normalizeQueryData } from "../utils.js";
|
|
1
|
+
import { useCallback, useEffect, useInsertionEffect, useMemo, useRef, } from "react";
|
|
2
|
+
import { useQuery, useMutation, hashKey, } from "@tanstack/react-query";
|
|
3
|
+
import { invalidateTargets, normalizeQueryData, pickFetchOptions, useMountQueryClient, } from "../utils.js";
|
|
4
|
+
/**
|
|
5
|
+
* A ref to `value` as of the last committed render, for code that runs outside
|
|
6
|
+
* render: event handlers, timers, effects and TanStack callbacks.
|
|
7
|
+
*
|
|
8
|
+
* Assigning the ref during render would also publish renders that React throws
|
|
9
|
+
* away, such as a transition that suspends or one that a more urgent update
|
|
10
|
+
* interrupts. The tree still on screen would then act on props it never showed,
|
|
11
|
+
* like calling a method it does not render. An insertion effect runs only when
|
|
12
|
+
* its render commits, and before every layout and passive effect of that
|
|
13
|
+
* commit, so no effect anywhere in the tree reads the previous commit's value.
|
|
14
|
+
* React's own `useEffectEvent` also swaps in its new function during the
|
|
15
|
+
* commit, ahead of layout effects. Unlike `useLayoutEffect`, an insertion
|
|
16
|
+
* effect does not warn in a React 18 server render. The initial value serves
|
|
17
|
+
* anything that runs before the first commit.
|
|
18
|
+
*/
|
|
19
|
+
function useCommittedRef(value) {
|
|
20
|
+
const ref = useRef(value);
|
|
21
|
+
useInsertionEffect(() => {
|
|
22
|
+
ref.current = value;
|
|
23
|
+
});
|
|
24
|
+
return ref;
|
|
25
|
+
}
|
|
4
26
|
/**
|
|
5
27
|
* A unified hook for calling canister methods that automatically handles
|
|
6
28
|
* both query and mutation methods based on the Candid interface.
|
|
@@ -13,12 +35,12 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
13
35
|
return reactor.isQueryMethod(functionName);
|
|
14
36
|
}, [reactor, functionName]);
|
|
15
37
|
const functionType = isQuery ? "query" : "update";
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onSuccessRef
|
|
21
|
-
onErrorRef
|
|
38
|
+
useMountQueryClient(reactor.queryClient);
|
|
39
|
+
// The committed render's callbacks, read at dispatch time: this keeps a
|
|
40
|
+
// rerendered closure from being ignored, and keeps callback identity out of
|
|
41
|
+
// the effect deps.
|
|
42
|
+
const onSuccessRef = useCommittedRef(onSuccess);
|
|
43
|
+
const onErrorRef = useCommittedRef(onError);
|
|
22
44
|
// Build the key for a given set of call arguments.
|
|
23
45
|
//
|
|
24
46
|
// A custom `queryKey` is appended to the canister/function prefix rather than
|
|
@@ -68,15 +90,25 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
68
90
|
// case that previously never notified at all.
|
|
69
91
|
const notifiedSuccessAt = useRef(undefined);
|
|
70
92
|
const notifiedErrorAt = useRef(undefined);
|
|
71
|
-
const { status, data, error, dataUpdatedAt, errorUpdatedAt } = queryResult;
|
|
93
|
+
const { status, data, error, dataUpdatedAt, errorUpdatedAt, isPlaceholderData, isFetched, } = queryResult;
|
|
72
94
|
useEffect(() => {
|
|
73
95
|
if (!isQuery)
|
|
74
96
|
return;
|
|
97
|
+
// Placeholder data also has `status: "success"`, but no call has returned
|
|
98
|
+
// it: it is the `placeholderData` option, or with `keepPreviousData` the
|
|
99
|
+
// previous args' result standing in while this call is in flight.
|
|
100
|
+
if (isPlaceholderData)
|
|
101
|
+
return;
|
|
102
|
+
// So does `initialData`: an entry starts with it, and `reset()` puts it
|
|
103
|
+
// back, before any fetch of the entry has settled. The first fetch that
|
|
104
|
+
// settles makes the entry fetched, and its result is reported below.
|
|
105
|
+
if (!isFetched)
|
|
106
|
+
return;
|
|
75
107
|
if (status === "success" && dataUpdatedAt !== notifiedSuccessAt.current) {
|
|
76
108
|
notifiedSuccessAt.current = dataUpdatedAt;
|
|
77
109
|
onSuccessRef.current?.(data);
|
|
78
110
|
}
|
|
79
|
-
}, [isQuery, status, data, dataUpdatedAt]);
|
|
111
|
+
}, [isQuery, status, data, dataUpdatedAt, isPlaceholderData, isFetched]);
|
|
80
112
|
useEffect(() => {
|
|
81
113
|
if (!isQuery)
|
|
82
114
|
return;
|
|
@@ -85,11 +117,67 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
85
117
|
onErrorRef.current?.(error);
|
|
86
118
|
}
|
|
87
119
|
}, [isQuery, status, error, errorUpdatedAt]);
|
|
120
|
+
// `call(args)` reports its own outcome, once per call, because the args it
|
|
121
|
+
// fetched usually key an entry this observer does not watch. When they key
|
|
122
|
+
// the entry it does watch, the effects above see the same settle, and each
|
|
123
|
+
// callback used to fire twice for one call. So the settle that ends a call's
|
|
124
|
+
// fetch is marked as notified when it lands in the observed entry, and the
|
|
125
|
+
// effects skip it.
|
|
126
|
+
//
|
|
127
|
+
// A query cache listener sets that mark while TanStack dispatches the
|
|
128
|
+
// settle, before any render can show it. Matching a settle up by its
|
|
129
|
+
// timestamp afterwards could not tell settles apart: two in one millisecond
|
|
130
|
+
// share a timestamp. And a call that an identity switch cancels settles
|
|
131
|
+
// nothing: TanStack reverts the entry to its previous result, timestamp
|
|
132
|
+
// included, so the call's outcome looked reported already, and neither the
|
|
133
|
+
// call nor the effects reported it.
|
|
134
|
+
const observedKeyRef = useCommittedRef(queryKey);
|
|
135
|
+
const markCallSettle = (calledKey) => {
|
|
136
|
+
const { queryClient } = reactor;
|
|
137
|
+
// The hash TanStack files the called entry under, worked out the way
|
|
138
|
+
// `fetchQuery` does. The listener compares it with hashes TanStack has
|
|
139
|
+
// already computed rather than hashing keys itself: the QueryClient may be
|
|
140
|
+
// shared with the app, whose keys a custom `queryKeyHashFn` can let hold
|
|
141
|
+
// values that `hashKey` throws on, inside TanStack's dispatch.
|
|
142
|
+
const calledHash = queryClient.defaultQueryOptions({
|
|
143
|
+
queryKey: calledKey,
|
|
144
|
+
}).queryHash;
|
|
145
|
+
let settled = false;
|
|
146
|
+
return queryClient.getQueryCache().subscribe((event) => {
|
|
147
|
+
if (settled || event.type !== "updated")
|
|
148
|
+
return;
|
|
149
|
+
const { action, query } = event;
|
|
150
|
+
// A fetch settles with one of these. `setQueryData` dispatches a
|
|
151
|
+
// success too, flagged manual, and it does not end this call's fetch.
|
|
152
|
+
const isSettle = action.type === "error" || (action.type === "success" && !action.manual);
|
|
153
|
+
if (!isSettle || query.queryHash !== calledHash)
|
|
154
|
+
return;
|
|
155
|
+
settled = true;
|
|
156
|
+
if (hashKey(calledKey) !== hashKey(observedKeyRef.current))
|
|
157
|
+
return;
|
|
158
|
+
if (action.type === "success") {
|
|
159
|
+
notifiedSuccessAt.current = query.state.dataUpdatedAt;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
notifiedErrorAt.current = query.state.errorUpdatedAt;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
88
166
|
// ============================================================================
|
|
89
167
|
// Mutation Implementation
|
|
90
168
|
// ============================================================================
|
|
91
169
|
const mutationResult = useMutation({
|
|
92
170
|
mutationKey: queryKey,
|
|
171
|
+
// The hook's `retry`, `retryDelay`, `networkMode` and `meta`, the options
|
|
172
|
+
// that decide how a call runs, as the query branch's `call()` applies
|
|
173
|
+
// them. They reached only the query branch, so an update's call ignored
|
|
174
|
+
// them: it stayed paused offline under `networkMode: "always"` and
|
|
175
|
+
// reached the MutationCache callbacks without the hook's `meta`. Unset
|
|
176
|
+
// ones are left to the QueryClient's mutation defaults, which retry
|
|
177
|
+
// nothing unless the app set `mutations.retry`: each attempt of an
|
|
178
|
+
// update is a new call the canister runs, so only a `retry` given here
|
|
179
|
+
// or in those defaults sends one again.
|
|
180
|
+
...pickFetchOptions(queryOptions),
|
|
93
181
|
// Normalized like the query branch, so `data`, `call()` and `onSuccess`
|
|
94
182
|
// mean the same thing for both kinds of method. The hook cannot type the
|
|
95
183
|
// two branches apart: a Candid service type does not say which methods
|
|
@@ -99,23 +187,62 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
99
187
|
args: mutationArgs ?? args,
|
|
100
188
|
callConfig,
|
|
101
189
|
}))),
|
|
102
|
-
onSuccess
|
|
190
|
+
// Invalidation first, then `onSuccess`, as `useActorMutation` and
|
|
191
|
+
// `createMutation` do. TanStack Query waits for the promise returned
|
|
192
|
+
// here before it settles the mutation, so `call()` resolves, and
|
|
193
|
+
// `isPending` turns false, once the invalidated queries that are in use
|
|
194
|
+
// have refetched, and `onSuccess` reads the refetched data. A refetch
|
|
195
|
+
// that fails does not reject `invalidateQueries`, so it cannot turn the
|
|
196
|
+
// update, which has already run on the canister, into a failure.
|
|
197
|
+
onSuccess: async (data) => {
|
|
198
|
+
await invalidateTargets(reactor, invalidateQueries, callConfig);
|
|
103
199
|
onSuccessRef.current?.(data);
|
|
104
|
-
// Invalidate specified queries after successful mutation
|
|
105
|
-
if (invalidateQueries && invalidateQueries.length > 0) {
|
|
106
|
-
invalidateQueries.forEach((key) => {
|
|
107
|
-
void reactor.queryClient.invalidateQueries({ queryKey: key });
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
200
|
},
|
|
111
201
|
onError: (error) => {
|
|
112
202
|
onErrorRef.current?.(error);
|
|
113
203
|
},
|
|
114
204
|
}, reactor.queryClient);
|
|
115
205
|
// ============================================================================
|
|
116
|
-
//
|
|
206
|
+
// Refetch and Call Functions
|
|
117
207
|
// ============================================================================
|
|
118
|
-
|
|
208
|
+
// A query's `call()` and `refetch()` resolve with the answer for the
|
|
209
|
+
// principal signed in when they settle. `ClientManager.updateAgent` cancels
|
|
210
|
+
// a fetch in flight when a sign-in or sign-out switches the principal, so
|
|
211
|
+
// that the previous principal's answer is never cached. TanStack then
|
|
212
|
+
// resolves the fetch with the data it puts the entry back to, which is the
|
|
213
|
+
// previous principal's, or rejects it with a `CancelledError` when the entry
|
|
214
|
+
// had none, and a call used to resolve with, and report, whichever it got.
|
|
215
|
+
// Through `fetchAcrossIdentitySwitch` it runs again for the principal signed
|
|
216
|
+
// in, as `reactor.fetchQuery()` and the factories' `fetch()` do. When the
|
|
217
|
+
// principal switches during that run too, and during each of two more, that
|
|
218
|
+
// rejects with a `CallError`, which is reported to `onError` like any other
|
|
219
|
+
// failure.
|
|
220
|
+
const refetchLatest = async () => {
|
|
221
|
+
if (!isQuery)
|
|
222
|
+
return undefined;
|
|
223
|
+
let runs = 0;
|
|
224
|
+
try {
|
|
225
|
+
const result = await reactor.clientManager.fetchAcrossIdentitySwitch(() =>
|
|
226
|
+
// A run after a switch joins the refetch the switch started for
|
|
227
|
+
// this entry, rather than cancel it and start another.
|
|
228
|
+
queryResult.refetch(runs++ === 0 ? undefined : { cancelRefetch: false }));
|
|
229
|
+
// TanStack's `refetch()` resolves even when the fetch fails, with the
|
|
230
|
+
// entry's last answer still in the result. After a sign-in or sign-out
|
|
231
|
+
// that is the previous principal's: the entry is put back to it when
|
|
232
|
+
// the switch cancels a fetch, and keeps it when the new principal's
|
|
233
|
+
// refetch fails. So a failed refetch resolves `undefined`, as a failed
|
|
234
|
+
// `call(args)` does, and the effects report the failure to `onError`.
|
|
235
|
+
// The hook's `data` keeps the last answer, as TanStack's does.
|
|
236
|
+
return result.isError ? undefined : result.data;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
// Only that CallError: `refetch()` itself never rejects. The effects
|
|
240
|
+
// report what the entry settles with, and it settles nothing for this.
|
|
241
|
+
onErrorRef.current?.(error);
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const callLatest = async (callArgs) => {
|
|
119
246
|
if (isQuery) {
|
|
120
247
|
// For queries, refetch with new args if provided
|
|
121
248
|
if (callArgs !== undefined) {
|
|
@@ -124,22 +251,41 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
124
251
|
// entry — poisoning it for every other reader — and let fetchQuery
|
|
125
252
|
// dedupe onto an in-flight request for the old args, returning that
|
|
126
253
|
// response as though it answered this one.
|
|
254
|
+
const calledKey = buildQueryKey(callArgs);
|
|
255
|
+
// Reported here rather than by the observer effects: this result
|
|
256
|
+
// usually lands under a key the mounted observer (bound to the hook's
|
|
257
|
+
// own args) does not watch. When it is that key, `markCallSettle` has
|
|
258
|
+
// already kept the effects from reporting it as well. Either way the
|
|
259
|
+
// callbacks get what the call settles with.
|
|
127
260
|
try {
|
|
128
|
-
const result = await reactor.
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
261
|
+
const result = await reactor.clientManager.fetchAcrossIdentitySwitch(async () => {
|
|
262
|
+
// Each run marks the settle of its own fetch. A run a switch
|
|
263
|
+
// overtook may have settled with the previous principal's answer,
|
|
264
|
+
// which the effects must not report either.
|
|
265
|
+
const stopMarking = markCallSettle(calledKey);
|
|
266
|
+
try {
|
|
267
|
+
return await reactor.queryClient.fetchQuery({
|
|
268
|
+
// The options the hook's own fetches run with: `retry`,
|
|
269
|
+
// `retryDelay`, `networkMode` and `meta`. With only a key and
|
|
270
|
+
// a function, a call ran on the QueryClient's defaults. It
|
|
271
|
+
// failed on the first error the hook retried through, stayed
|
|
272
|
+
// paused offline under `networkMode: "always"`, and reached
|
|
273
|
+
// the QueryCache callbacks without the hook's `meta`.
|
|
274
|
+
...pickFetchOptions(queryOptions),
|
|
275
|
+
queryKey: calledKey,
|
|
276
|
+
// Normalize for the same reason as the observer's queryFn.
|
|
277
|
+
queryFn: async () => normalizeQueryData((await reactor.callMethod({
|
|
278
|
+
functionName,
|
|
279
|
+
args: callArgs,
|
|
280
|
+
callConfig,
|
|
281
|
+
}))),
|
|
282
|
+
staleTime: 0,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
stopMarking();
|
|
287
|
+
}
|
|
137
288
|
});
|
|
138
|
-
// Dispatched here rather than by the observer effect: this result
|
|
139
|
-
// lands under the called args' key, which the mounted observer (bound
|
|
140
|
-
// to the hook's own args) does not watch. That separation is also why
|
|
141
|
-
// this can no longer double-fire the way it did when both wrote to
|
|
142
|
-
// the same key.
|
|
143
289
|
onSuccessRef.current?.(result);
|
|
144
290
|
return result;
|
|
145
291
|
}
|
|
@@ -149,8 +295,7 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
149
295
|
}
|
|
150
296
|
}
|
|
151
297
|
// Otherwise just refetch
|
|
152
|
-
|
|
153
|
-
return data;
|
|
298
|
+
return refetchLatest();
|
|
154
299
|
}
|
|
155
300
|
else {
|
|
156
301
|
// For mutations, execute with provided args
|
|
@@ -158,19 +303,11 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
158
303
|
.mutateAsync(callArgs)
|
|
159
304
|
.catch(() => undefined);
|
|
160
305
|
}
|
|
161
|
-
}
|
|
162
|
-
isQuery,
|
|
163
|
-
reactor,
|
|
164
|
-
functionName,
|
|
165
|
-
callConfig,
|
|
166
|
-
buildQueryKey,
|
|
167
|
-
queryResult,
|
|
168
|
-
mutationResult,
|
|
169
|
-
]);
|
|
306
|
+
};
|
|
170
307
|
// ============================================================================
|
|
171
308
|
// Reset Function
|
|
172
309
|
// ============================================================================
|
|
173
|
-
const
|
|
310
|
+
const resetLatest = () => {
|
|
174
311
|
if (isQuery) {
|
|
175
312
|
// Reset, not remove. `removeQueries` drops the entry without notifying
|
|
176
313
|
// its observers, so this hook kept rendering the old data while bound to
|
|
@@ -184,17 +321,24 @@ export function useActorMethod({ reactor, functionName, args, callConfig, queryK
|
|
|
184
321
|
else {
|
|
185
322
|
mutationResult.reset();
|
|
186
323
|
}
|
|
187
|
-
}
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
324
|
+
};
|
|
325
|
+
// `call`, `reset` and `refetch` keep one identity for the life of the
|
|
326
|
+
// component, as TanStack's own `refetch`, `mutate` and `reset` do, and run
|
|
327
|
+
// the latest committed render's implementation above when invoked. They used
|
|
328
|
+
// to be `useCallback`s listing the query and mutation results, which TanStack
|
|
329
|
+
// Query returns fresh every render, so they changed every render too. An
|
|
330
|
+
// effect that lists one — `react-hooks/exhaustive-deps` requires it as soon
|
|
331
|
+
// as the effect calls it — then re-ran after every render its own call
|
|
332
|
+
// caused: an unbounded loop of canister calls, state-changing ones for an
|
|
333
|
+
// update method.
|
|
334
|
+
const latest = useCommittedRef({
|
|
335
|
+
call: callLatest,
|
|
336
|
+
reset: resetLatest,
|
|
337
|
+
refetch: refetchLatest,
|
|
338
|
+
});
|
|
339
|
+
const call = useCallback((callArgs) => latest.current.call(callArgs), []);
|
|
340
|
+
const reset = useCallback(() => latest.current.reset(), []);
|
|
341
|
+
const refetch = useCallback(() => latest.current.refetch(), []);
|
|
198
342
|
// ============================================================================
|
|
199
343
|
// Return Unified Result
|
|
200
344
|
// ============================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActorMethod.js","sourceRoot":"","sources":["../../src/hooks/useActorMethod.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useActorMethod.js","sourceRoot":"","sources":["../../src/hooks/useActorMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAA;AACd,OAAO,EACL,QAAQ,EACR,WAAW,EACX,OAAO,GAKR,MAAM,uBAAuB,CAAA;AAa9B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AA2LpB;;;;;;;;;;;;;;GAcG;AACH,SAAS,eAAe,CAAI,KAAQ;IAClC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACzB,kBAAkB,CAAC,GAAG,EAAE;QACtB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACrB,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAI5B,EACA,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,QAAQ,EAAE,cAAc,EACxB,OAAO,GAAG,IAAI,EACd,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,GAAG,YAAY,EACsC;IAQrD,0DAA0D;IAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;QAC3B,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;QAC7D,OAAO,OAAO,CAAC,aAAa,CAAC,YAAY,C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O,EAAE,CAAC;QACZ,OAAO;YACL,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,OAAO,EAAE,IAAI;YACb,YAAY;YACZ,IAAI;YACJ,KAAK;YACL,OAAO;YACP,WAAW;SACwC,CAAA;IACvD,CAAC;SAAM,CAAC;QACN,OAAO;YACL,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,OAAO,EAAE,cAAc,CAAC,OAAO;YAC/B,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,OAAO,EAAE,KAAK;YACd,YAAY;YACZ,IAAI;YACJ,KAAK;YACL,OAAO;YACP,cAAc;SACqC,CAAA;IACvD,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAGpC,OAAoC;IACpC,OAAO;QACL;;WAEG;QACH,SAAS,EAAE,CACT,MAGC,EACD,EAAE,CACF,cAAc,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAIlC,CAAC;KACL,CAAA;AACH,CAAC"}
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import { UseMutationOptions, UseMutationResult
|
|
1
|
+
import { UseMutationOptions, UseMutationResult } from "@tanstack/react-query";
|
|
2
2
|
import { Reactor, ReactorArgs, ReactorReturnOk, FunctionName, TransformKey, ReactorReturnErr, CanisterError, ErrResult, ActorMethodReturnType, TransformReturnRegistry } from "@ic-reactor/core";
|
|
3
3
|
import { CallConfig } from "@icp-sdk/core/agent";
|
|
4
|
-
|
|
4
|
+
import type { InvalidationTarget } from "../types.js";
|
|
5
|
+
export interface UseActorMutationParameters<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TOnMutateResult = unknown> extends Omit<UseMutationOptions<ReactorReturnOk<Service, Method, Transform>, ReactorReturnErr<Service, Method, Transform>, ReactorArgs<Service, Method, Transform>, TOnMutateResult>, "mutationFn"> {
|
|
5
6
|
reactor: Reactor<Service, Transform>;
|
|
6
7
|
functionName: Method;
|
|
7
8
|
callConfig?: CallConfig;
|
|
8
9
|
/**
|
|
9
|
-
* Queries to invalidate upon successful mutation
|
|
10
|
+
* Queries to invalidate upon successful mutation, awaited before
|
|
11
|
+
* `onSuccess` runs.
|
|
10
12
|
*
|
|
11
|
-
*
|
|
12
|
-
* `
|
|
13
|
-
*
|
|
13
|
+
* Each entry is a query key, a query object or query factory, or a
|
|
14
|
+
* `{ functionName, args? }` method of `reactor`; see
|
|
15
|
+
* {@link InvalidationTarget}. `undefined` entries are skipped, so
|
|
16
|
+
* `[maybeQuery]` is safe when the optional query object is absent.
|
|
14
17
|
*/
|
|
15
|
-
invalidateQueries?:
|
|
18
|
+
invalidateQueries?: InvalidationTarget<Service, Transform>[];
|
|
16
19
|
/**
|
|
17
20
|
* Callback for canister-level business logic errors.
|
|
18
21
|
* Called when the canister returns a Result { Err: E } variant.
|
|
19
22
|
* Separate from `onError`, which fires for all errors including network failures.
|
|
20
23
|
*/
|
|
21
|
-
onCanisterError?: (error: CanisterError<TransformReturnRegistry<ErrResult<ActorMethodReturnType<Service[Method]
|
|
24
|
+
onCanisterError?: (error: CanisterError<TransformReturnRegistry<ErrResult<ActorMethodReturnType<Service[Method]>>, Service>[Transform]>, variables: ReactorArgs<Service, Method, Transform>) => void;
|
|
22
25
|
}
|
|
23
|
-
export type UseActorMutationConfig<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid"> = Omit<UseActorMutationParameters<Service, Method, Transform>, "reactor">;
|
|
24
|
-
export type UseActorMutationResult<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid"> = UseMutationResult<ReactorReturnOk<Service, Method, Transform>, ReactorReturnErr<Service, Method, Transform>, ReactorArgs<Service, Method, Transform
|
|
26
|
+
export type UseActorMutationConfig<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TOnMutateResult = unknown> = Omit<UseActorMutationParameters<Service, Method, Transform, TOnMutateResult>, "reactor">;
|
|
27
|
+
export type UseActorMutationResult<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TOnMutateResult = unknown> = UseMutationResult<ReactorReturnOk<Service, Method, Transform>, ReactorReturnErr<Service, Method, Transform>, ReactorArgs<Service, Method, Transform>, TOnMutateResult>;
|
|
25
28
|
/**
|
|
26
29
|
* Hook for executing mutation calls on a canister.
|
|
27
30
|
* Use this for component-level mutation flows.
|
|
28
31
|
* For non-React usage, prefer `createMutation(...).execute(args)`.
|
|
29
32
|
*
|
|
30
33
|
* @example
|
|
31
|
-
* const { mutate, isPending } =
|
|
34
|
+
* const { mutate, isPending } = useReactorMutation({
|
|
32
35
|
* reactor,
|
|
33
36
|
* functionName: "transfer",
|
|
34
37
|
* onSuccess: () => console.log("Success!"),
|
|
@@ -44,5 +47,5 @@ export type UseActorMutationResult<Service, Method extends FunctionName<Service>
|
|
|
44
47
|
* // Non-React execution path
|
|
45
48
|
* await transferMutation.execute([{ to: "aaaaa-aa", amount: "100" }])
|
|
46
49
|
*/
|
|
47
|
-
export declare const useActorMutation: <Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid">({ reactor, functionName, invalidateQueries, onSuccess, onError, onCanisterError, callConfig, ...options }: UseActorMutationParameters<Service, Method, Transform>) => UseActorMutationResult<Service, Method, Transform>;
|
|
50
|
+
export declare const useActorMutation: <Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TOnMutateResult = unknown>({ reactor, functionName, invalidateQueries, onSuccess, onError, onCanisterError, callConfig, ...options }: UseActorMutationParameters<Service, Method, Transform, TOnMutateResult>) => UseActorMutationResult<Service, Method, Transform, TOnMutateResult>;
|
|
48
51
|
//# sourceMappingURL=useActorMutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActorMutation.d.ts","sourceRoot":"","sources":["../../src/hooks/useActorMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useActorMutation.d.ts","sourceRoot":"","sources":["../../src/hooks/useActorMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,OAAO,EACP,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAEhB,aAAa,EACb,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,WAAW,0BAA0B,CACzC,OAAO,EACP,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,EACpC,SAAS,SAAS,YAAY,GAAG,QAAQ,EACzC,eAAe,GAAG,OAAO,CACzB,SAAQ,IAAI,CACZ,kBAAkB,CAChB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAC3C,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAC5C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EACvC,eAAe,CAChB,EACD,YAAY,CACb;IACC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAA;IAC5D;;;;OAIG;IAC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2
|
import { useMutation, } from "@tanstack/react-query";
|
|
3
3
|
import { isCanisterError, } from "@ic-reactor/core";
|
|
4
|
+
import { invalidateTargets, useMountQueryClient } from "../utils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Hook for executing mutation calls on a canister.
|
|
6
7
|
* Use this for component-level mutation flows.
|
|
7
8
|
* For non-React usage, prefer `createMutation(...).execute(args)`.
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
|
-
* const { mutate, isPending } =
|
|
11
|
+
* const { mutate, isPending } = useReactorMutation({
|
|
11
12
|
* reactor,
|
|
12
13
|
* functionName: "transfer",
|
|
13
14
|
* onSuccess: () => console.log("Success!"),
|
|
@@ -24,21 +25,15 @@ import { isCanisterError, } from "@ic-reactor/core";
|
|
|
24
25
|
* await transferMutation.execute([{ to: "aaaaa-aa", amount: "100" }])
|
|
25
26
|
*/
|
|
26
27
|
export const useActorMutation = ({ reactor, functionName, invalidateQueries, onSuccess, onError, onCanisterError, callConfig, ...options }) => {
|
|
28
|
+
useMountQueryClient(reactor.queryClient);
|
|
27
29
|
const mutationFn = useCallback(async (args) => reactor.callMethod({ functionName, callConfig, args }), [reactor, functionName, callConfig]);
|
|
28
30
|
const handleSuccess = useCallback(async (...params) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// whenever the optional query object is absent — would invalidate every
|
|
34
|
-
// query in the client, including an app's unrelated non-canister ones.
|
|
35
|
-
// `createMutation.invalidateAll` already filters the same way.
|
|
36
|
-
await Promise.all(invalidateQueries
|
|
37
|
-
.filter((queryKey) => queryKey !== undefined)
|
|
38
|
-
.map((queryKey) => reactor.queryClient.invalidateQueries({ queryKey })));
|
|
39
|
-
}
|
|
31
|
+
// Undefined entries are skipped: React Query reads
|
|
32
|
+
// `{ queryKey: undefined }` as "match everything", and the natural
|
|
33
|
+
// `[maybeQuery]` idiom produces one whenever the query is absent.
|
|
34
|
+
await invalidateTargets(reactor, invalidateQueries, callConfig);
|
|
40
35
|
await onSuccess?.(...params);
|
|
41
|
-
}, [reactor, invalidateQueries, onSuccess]);
|
|
36
|
+
}, [reactor, invalidateQueries, onSuccess, callConfig]);
|
|
42
37
|
const handleError = useCallback(async (error, variables, context, mutation) => {
|
|
43
38
|
if (isCanisterError(error)) {
|
|
44
39
|
onCanisterError?.(error, variables);
|
|
@@ -60,6 +55,12 @@ export const useActorMutation = ({ reactor, functionName, invalidateQueries, onS
|
|
|
60
55
|
// A fresh object per render costs nothing here: `setOptions` diffs the values
|
|
61
56
|
// rather than the reference.
|
|
62
57
|
return useMutation({
|
|
58
|
+
// Keyed like `createMutation`'s hook and `useActorMethod`'s mutations,
|
|
59
|
+
// so `useIsMutating({ mutationKey })`, `useMutationState` and defaults
|
|
60
|
+
// registered with `setMutationDefaults` can find this one too. An
|
|
61
|
+
// explicit `mutationKey` in the options still wins.
|
|
62
|
+
mutationKey: reactor.getQueryOptions({ functionName, callConfig })
|
|
63
|
+
.queryKey,
|
|
63
64
|
...options,
|
|
64
65
|
mutationFn,
|
|
65
66
|
onSuccess: handleSuccess,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActorMutation.js","sourceRoot":"","sources":["../../src/hooks/useActorMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"useActorMutation.js","sourceRoot":"","sources":["../../src/hooks/useActorMutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EACL,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAOL,eAAe,GAKhB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAoEpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG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E;IACF,6EAA6E;IAC7E,8EAA8E;IAC9E,6BAA6B;IAC7B,OAAO,WAAW,CAChB;QACE,uEAAuE;QACvE,uEAAuE;QACvE,kEAAkE;QAClE,oDAAoD;QACpD,WAAW,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;aAC/D,QAAQ;QACX,GAAG,OAAO;QACV,UAAU;QACV,SAAS,EAAE,aAAa;QACxB,OAAO,EAAE,WAAW;KACrB,EACD,OAAO,CAAC,WAAW,CACpB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
|
|
1
|
+
import { QueryKey, QueryObserverOptions, UseQueryResult, type SkipToken } from "@tanstack/react-query";
|
|
2
2
|
import { FunctionName, Reactor, TransformKey, ReactorArgs, ReactorReturnOk, ReactorQueryData, ReactorReturnErr } from "@ic-reactor/core";
|
|
3
3
|
import { CallConfig } from "@icp-sdk/core/agent";
|
|
4
4
|
export interface UseActorQueryParameters<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", Selected = ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>> extends Omit<QueryObserverOptions<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, ReactorReturnErr<Service, Method, Transform>, Selected, ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, QueryKey>, "queryKey" | "queryFn"> {
|
|
5
5
|
reactor: Reactor<Service, Transform>;
|
|
6
6
|
functionName: Method;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The method's arguments, or TanStack Query's `skipToken` while they are
|
|
9
|
+
* not known: the query then waits without fetching, in an entry of its own
|
|
10
|
+
* under its method's key, which no call's key shares, so it shows no data
|
|
11
|
+
* until the arguments arrive.
|
|
12
|
+
*/
|
|
13
|
+
args?: ReactorArgs<Service, Method, Transform> | SkipToken;
|
|
8
14
|
callConfig?: CallConfig;
|
|
9
15
|
queryKey?: QueryKey;
|
|
10
16
|
}
|
|
@@ -14,19 +20,26 @@ export type UseActorQueryResult<Service, Method extends FunctionName<Service>, T
|
|
|
14
20
|
* Hook for executing query calls on a canister.
|
|
15
21
|
*
|
|
16
22
|
* @example
|
|
17
|
-
* const { data, isLoading } =
|
|
23
|
+
* const { data, isLoading } = useReactorQuery({
|
|
18
24
|
* reactor,
|
|
19
25
|
* functionName: "getUser",
|
|
20
26
|
* args: ["user-123"],
|
|
21
27
|
* })
|
|
22
28
|
*
|
|
23
29
|
* // With select transformation
|
|
24
|
-
* const { data } =
|
|
30
|
+
* const { data } = useReactorQuery({
|
|
25
31
|
* reactor,
|
|
26
32
|
* functionName: "getUser",
|
|
27
33
|
* args: ["user-123"],
|
|
28
34
|
* select: (user) => user.name,
|
|
29
35
|
* })
|
|
36
|
+
*
|
|
37
|
+
* // Wait for the args: no fetch until userId is known
|
|
38
|
+
* const { data } = useReactorQuery({
|
|
39
|
+
* reactor,
|
|
40
|
+
* functionName: "getUser",
|
|
41
|
+
* args: userId ? [userId] : skipToken,
|
|
42
|
+
* })
|
|
30
43
|
*/
|
|
31
44
|
export declare const useActorQuery: <Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", Selected = ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>>({ reactor, functionName, args, callConfig, queryKey: defaultQueryKey, ...options }: UseActorQueryParameters<Service, Method, Transform, Selected>) => UseActorQueryResult<Service, Method, Transform, Selected>;
|
|
32
45
|
//# sourceMappingURL=useActorQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActorQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useActorQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"useActorQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useActorQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAGR,oBAAoB,EACpB,cAAc,EACd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