Create a reusable shared query object that can be used to auto de-duplicate and cache all data fetches, with auto-expiration and staleness checks.
Each queryName must be unique, and can only be declared once, most often in the top level scope. The queryName is used for logging only.
queryName
Example:
export const usersQuery = sharedQuery({ queryName: "users", queryFn: listUsers, persistTo: "indexedDb", staleMs: MS_PER_DAY, }); Copy
export const usersQuery = sharedQuery({ queryName: "users", queryFn: listUsers, persistTo: "indexedDb", staleMs: MS_PER_DAY, });
Create a reusable shared query object that can be used to auto de-duplicate and cache all data fetches, with auto-expiration and staleness checks.
Each
queryNamemust be unique, and can only be declared once, most often in the top level scope. The queryName is used for logging only.Example: