Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

createoptimisticactionsoptions.md

122 lines2.0 KB

Interface: CreateOptimisticActionsOptions<TVars, T>

Defined in: packages/db/src/types.ts:174

Options for the createOptimisticAction helper

Extends

Type Parameters

• TVars = unknown

• T extends object = Record<string, unknown>

Properties

autoCommit?

optional autoCommit: boolean;

Defined in: packages/db/src/types.ts:165

Inherited from

Omit.autoCommit

id?

optional id: string;

Defined in: packages/db/src/types.ts:163

Unique identifier for the transaction

Inherited from

Omit.id

metadata?

optional metadata: Record<string, unknown>;

Defined in: packages/db/src/types.ts:168

Custom metadata to associate with the transaction

Inherited from

Omit.metadata

mutationFn()

mutationFn: (vars, params) => Promise<any>;

Defined in: packages/db/src/types.ts:181

Function to execute the mutation on the server

Parameters

vars

TVars

params

MutationFnParams<T>

Returns

Promise<any>


onMutate()

onMutate: (vars) => void;

Defined in: packages/db/src/types.ts:179

Function to apply optimistic updates locally before the mutation completes

Parameters

vars

TVars

Returns

void