OptimisticRollback
Defined in: react/src/types.ts:307
What optimisticUpdate() resolves with: the way back to the value the
cache held before the update.
Example
Section titled “Example”const update = await postQuery.optimisticUpdate((post) => ({ ...post, likes: post.likes + 1n,}))// The call failed: show the post as it wasupdate.rollback()Properties
Section titled “Properties”rollback
Section titled “rollback”rollback: () =>
void
Defined in: react/src/types.ts:320
Write back the value the cache held before the update, with the time it was fetched, so it is as fresh or as stale as it was. A value that was invalidated is invalidated again, so a mounted query refetches it, as the refetch the update cancelled would have.
It does nothing when the update wrote nothing, or when another principal has signed in or out since: the value was the previous principal’s, and the sign-in has already removed or refetched it. It restores that value even if a fetch or another update has written since; invalidate the query afterwards when the canister’s current value matters.
Returns
Section titled “Returns”void