Class MutationResult<TVariables, TData>
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Mutation handle returned by UseMutation<TVariables, TData>(MutationOptions<TVariables, TData>). Exposes Status flags + Data / Error / Variables snapshots + Mutate(TVariables) / MutateAsync(TVariables) / Reset() imperative API.
public sealed class MutationResult<TVariables, TData>
Type Parameters
TVariablesTData
- Inheritance
-
objectMutationResult<TVariables, TData>
Properties
- Data
Result of the most recent call, and default under every status but Success: starting a call clears it, so a pending call never shows an earlier call's result, and a call that fails — its
OnSuccessthrowing included — leaves none behind.
- Error
Exception from the last failed mutation, and null under every other status.
- FailureCount
How many attempts of the most recent call have failed, as TanStack's
failureCount: zero when a call starts or succeeds, one more for each failed attempt a Retry retries, and one more again when the call fails for good.
- FailureReason
The exception of the most recent failed attempt of the call, as TanStack's
failureReason: null when a call starts or succeeds, and still the last attempt's failure while the call waits to retry.
- IsError
True when the last mutation threw.
- IsIdle
True when no mutation has run yet (or it was reset).
- IsPaused
True while the call waits for a connection or for the application to become visible again, as TanStack's
isPaused. See NetworkMode.
- IsPending
True while a mutation is in flight.
- IsSuccess
True when the last mutation completed successfully.
- Status
Current lifecycle status of the mutation.
- Variables
Variables passed to the most recent mutation invocation, or default.
Methods
- Mutate(TVariables)
Fire-and-forget mutation that does not return a task.
- Mutate(TVariables, MutateOptions<TVariables, TData>?)
Fire-and-forget mutation whose own
optionscallbacks run after the hook options'.
- MutateAsync(TVariables)
Awaitable mutation. Rethrows the underlying exception on failure so callers can
try/catch; Error is also populated. The call settles the same whether or not the component is still mounted, since unmounting cancels nothing and a call made after the unmount runs.
- MutateAsync(TVariables, MutateOptions<TVariables, TData>?)
Awaitable mutation whose own
optionscallbacks run after the hook options'. Settles as MutateAsync(TVariables) does.