ReadonlyexpiryReadonlykeepReadonlylogReadonlymaxReadonlymaxReadonlyqueryReadonlyqueryReadonlyrefetchReadonlystaleDelete all currently cached data & all inflight promises.
Delete the cached data for one set of arguments.
Discard the oldest entries if the size exceeds the limit. The last remaining record cannot be deleted no matter what the limit is.
Get the AbortController to abort the inflight query (if any).
Note that once you get the controller, you can also get the signal easily
using controller.signal. So if you need both the controller and the
signal, just use this function.
Get the AbortSignal to check for query abortions.
Example:
const getUserQuery = sharedQuery({
queryName: "getUser",
queryFn: (userId: string) => {
// Get the signal for this current execution.
const signal = getUserQuery.getAbortSignal([userId]);
// Pass the signal to fetch so that it can be aborted.
const response = await fetch(`/users/${userId}`, { signal });
// Check for errors.
if (!response.ok) {
throw new Error(response.statusText);
}
// Return the data.
return await response.json();
},
});
Get the entire stored entry for a query key.
Keep track of mounted keys.
Set the data directly if the user obtained it from somewhere else.
Clean up mounted keys.
Please use sharedQuery() instead.