Class QueryOptions<TArg, TResult>
Options that are passed when creating a Query<TArg, TResult> or calling Use(QueryOptions<TArg, TResult>?).
public sealed record QueryOptions<TArg, TResult> : IEquatable<QueryOptions<TArg, TResult>>
Type Parameters
TArg
TResult
- Inheritance
-
QueryOptions<TArg, TResult>
- Implements
-
IEquatable<QueryOptions<TArg, TResult>>
- Inherited Members
Constructors
QueryOptions()
Options that are passed when creating a Query<TArg, TResult> or calling Use(QueryOptions<TArg, TResult>?).
public QueryOptions()
QueryOptions(QueryOptions)
Creates a strongly-typed QueryOptions<TArg, TResult> from a QueryOptions instance.
public QueryOptions(QueryOptions original)
Parameters
original
QueryOptions
Properties
Default
An instance of QueryOptions<TArg, TResult> with default values.
public static QueryOptions<TArg, TResult> Default { get; }
Property Value
- QueryOptions<TArg, TResult>
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<TResult>? OnDataChanged { get; init; }
Property Value
- Action<TResult>
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<TArg>>? OnFailure { get; init; }
Property Value
- Action<QueryFailureEventArgs<TArg>>
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<QuerySuccessEventArgs<TArg, TResult>>? OnSuccess { get; init; }
Property Value
- Action<QuerySuccessEventArgs<TArg, TResult>>
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; }
Property Value
Operators
implicit operator QueryOptions<TArg, TResult>(QueryOptions)
Converts an untyped QueryOptions instance into an QueryOptions<TArg, TResult>.
public static implicit operator QueryOptions<TArg, TResult>(QueryOptions original)
Parameters
original
QueryOptions
Returns
- QueryOptions<TArg, TResult>