Method SetQueryData
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
SetQueryData<T>(QueryKey, T)
Writes data into the entry queryKey names, creating it when there
is none, TanStack Query's setQueryData: the entry becomes Success
with fresh data and no error, and the queries reading it are told, re-rendering for what changed. The data is
shared structurally with what the entry held, as a request landing is. A request in flight is left
running and lands over it. A new entry nothing reads expires after
DefaultGcTime. A null data writes nothing.
public T? SetQueryData<T>(QueryKey queryKey, T data)
Parameters
queryKeyQueryKeydataT
Returns
- T
The data the entry holds afterwards; default when nothing was written.
Type Parameters
T
Exceptions
- InvalidOperationException
The entry holds data of another type.
SetQueryData<T>(QueryKey, Func<T?, T>)
SetQueryData<T>(QueryKey, T) with the data updater makes of the data
the entry holds, default when it holds none, as TanStack Query's functional updater. An updater
returning null writes nothing.
public T? SetQueryData<T>(QueryKey queryKey, Func<T?, T> updater)
Parameters
queryKeyQueryKeyupdaterFunc<T, T>
Returns
- T
The data the entry holds afterwards; default when nothing was written.
Type Parameters
T
Exceptions
- InvalidOperationException
The entry holds data of another type.