Skip to main content
browser.OptimisticLocalStore A view of the query results currently in the Bijection client for use within optimistic updates.

Methods

getQuery

▸ getQuery<Query>(query, ...args): undefined | FunctionReturnType<Query> Retrieve the result of a query from the client. Important: Query results should be treated as immutable! Always make new copies of structures within query results to avoid corrupting data within the client.

Type parameters

Parameters

Returns

undefined | FunctionReturnType<Query> The query result or undefined if the query is not currently in the client.

getAllQueries

▸ getAllQueries<Query>(query): { args: FunctionArgs<Query> ; value: undefined | FunctionReturnType<Query> }[] Retrieve the results and arguments of all queries with a given name. This is useful for complex optimistic updates that need to inspect and update many query results (for example updating a paginated list). Important: Query results should be treated as immutable! Always make new copies of structures within query results to avoid corrupting data within the client.

Type parameters

Parameters

Returns

{ args: FunctionArgs<Query> ; value: undefined | FunctionReturnType<Query> }[] An array of objects, one for each query of the given name. Each object includes:
  • args - The arguments object for the query.
  • value The query result or undefined if the query is loading.

setQuery

▸ setQuery<Query>(query, args, value): void Optimistically update the result of a query. This can either be a new value (perhaps derived from the old value from getQuery) or undefined to remove the query. Removing a query is useful to create loading states while Bijection recomputes the query results.

Type parameters

Parameters

Returns

void