API reference > @kontsedal/olas-core > createMutation
createMutation() function
A write owned by this controller's lifetime (§6). Either inline:
ts
const save = createMutation(ctx, {
mutate: (draft: Draft, { signal, deps }) => deps.api.save(draft, { signal }),
})or from a module-scope defineMutation(...), with this controller's lifecycle hooks layered on:
ts
const place = createMutation(ctx, createOrder, { onSuccess: () => toast('Placed') })Needs a query engine: mutations participate in the root's in-flight accounting, which waitForIdle() reads during SSR.
Signature:
typescript
export declare function createMutation<V, R>(ctx: Ctx, def: MutationDef<V, R>, hooks?: MutationHooks<V, R>): Mutation<V, R>;Parameters
Parameter | Type | Description |
|---|---|---|
ctx | ||
def | MutationDef<V, R> | |
hooks | MutationHooks<V, R> | (Optional) |
Returns:
Mutation<V, R>