Class MutationOptions<TVariables, TData, TContext>
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Options passed to UseMutation<TVariables, TData, TContext>(MutationOptions<TVariables, TData, TContext>): TanStack Query's
onMutate / onSuccess / onError / onSettled quartet. OnMutate runs
before MutationFn, and what it returns is the context each later callback of that call
receives — the place to snapshot and write an optimistic value, roll it back in OnError,
and finish in OnSettled. Where OnMutate throws or its task faults, or the
options declare none, the callbacks receive a default context. Every callback returns a task the call
waits for before the next stage, OnMutate included, so a context built from a request is
the task's result.
public sealed record MutationOptions<TVariables, TData, TContext>
Type Parameters
TVariablesTDataTContext
- Inheritance
-
objectMutationOptions<TVariables, TData, TContext>
Constructors
- MutationOptions(Func<TVariables, CancellationToken, VelvetTask<TData>>, Func<TVariables, VelvetTask<TContext>>?, Func<TData, TVariables, TContext?, VelvetTask>?, Func<Exception, TVariables, TContext?, VelvetTask>?, Func<TData?, Exception?, TVariables, TContext?, VelvetTask>?)
Options passed to UseMutation<TVariables, TData, TContext>(MutationOptions<TVariables, TData, TContext>): TanStack Query's
onMutate/onSuccess/onError/onSettledquartet. OnMutate runs before MutationFn, and what it returns is the context each later callback of that call receives — the place to snapshot and write an optimistic value, roll it back in OnError, and finish in OnSettled. Where OnMutate throws or its task faults, or the options declare none, the callbacks receive a default context. Every callback returns a task the call waits for before the next stage, OnMutate included, so a context built from a request is the task's result.