Class QueryOptions
A re-usable version of QueryOptions<TArg, TResult> without type arguments, which can be used to share query settings across multiple calls to endpoint.Use(options).
public sealed record QueryOptions : IEquatable<QueryOptions>
- Inheritance
-
QueryOptions
- Implements
- Inherited Members
Constructors
QueryOptions()
A re-usable version of QueryOptions<TArg, TResult> without type arguments, which can be used to share query settings across multiple calls to endpoint.Use(options).
public QueryOptions()
Properties
Default
An instance of QueryOptions<TArg, TResult> with default values.
public static QueryOptions Default { get; }
Property Value
OnDataChanged
A function that gets run when this query's data changes. Unlike OnSuccess, this is called if the query result is already cached.
public Action? OnDataChanged { get; init; }
Property Value
Remarks
Like OnSuccess, this is only called if the query is currently being observed.
OnFailure
A function that gets run when this query fails.
public Action<QueryFailureEventArgs>? OnFailure { get; init; }
Property Value
Remarks
This is only called when the query is currently being observed, which means:
-
If a query arg is changed while it is still fetching a previous arg,
OnFailure
will only be called for the latest arg. -
If the observing component is unmounted before the query finishes,
OnFailure
will not be called.
OnSuccess
A function that gets run when this query succeeds, including if the result was already cached. If the cached result is stale, this will not be called until the new result is fetched.
public Action<EventArgs>? OnSuccess { get; init; }
Property Value
Remarks
This is only called when the query is currently being observed, which means:
RefetchInterval
If not null, the query will be automatically re-fetched at this interval.
public TimeSpan? RefetchInterval { get; init; }
Property Value
Remarks
Automatic re-fetches will use the RetryHandler defined on the endpoint, not the one for this query.
If a query is used in multiple components withRefetchInterval
enabled and the same
Arg
, the query will be re-fetched at the shortest interval.
RetryHandler
If set, overrides the default RetryHandler for the endpoint.
To remove the endpoint's retry handler if it has one, set this to None.public IRetryHandler? RetryHandler { get; init; }
Property Value
StaleTime
The amount of time until this query is considered "stale". If not set, the DefaultStaleTime (zero by default) will be used instead.
If a cached query is used before it becomes stale, the component will receive the cached result and won't re-fetch the data. If a cached query is used after it becomes stale, the cached data will be used initially, but new data will be re-fetched in the background automatically. When set to MaxValue, queries will never be considered stale (unless they are manually invalidated).public TimeSpan? StaleTime { get; init; }