Skip to main content

sdk.apioptions

Home > @kittl/sdk > APIOptions

APIOptions type

Generic options for API operations that control how state changes are processed and tracked.

**Execution Modes:** - **Batch Mode**: Uses batchClient to accumulate operations without immediate state updates. Operations are executed on a working copy and committed together for better performance. - **Direct Mode**: Immediately applies changes to the state store with specified origin and history tracking. - **Default Mode**: When undefined, uses standard UI origin with tracked history.

**Change Tracking:** - origin: Identifies the source of changes (UI, Canvas, CRDT, Volatile) for state synchronization - historyOrigin: Controls whether changes appear in undo/redo history (Tracked/Untracked)

Signature:

export type APIOptions<T extends Record<string, unknown>> = {
batchClient: BatchClient<T>;
} | {
origin: Origin;
historyOrigin?: HistoryOrigins;
} | undefined;

References: BatchClient

Example

// Batch multiple operations for performance
const batchClient = designController.createBatchClient();
api.image.addImage(params, { batchClient });
api.board.createStandardBoard(params, { batchClient });
batchClient.commit(); // Apply all changes at once

// Direct operation with custom tracking
api.image.addImage(params, {
origin: Origin.CANVAS,
historyOrigin: HistoryOrigins.Untracked
});