Interface IQuery
A query with unknown type arguments.
public interface IQuery : IDisposable
- Inherited Members
Properties
Error
The exception thrown the last time the query failed with this arg, or null
if the
query has never failed with this arg.
Exception? Error { get; }
Property Value
HasData
True if the query has succeeded and returned a non-null response.
bool HasData { get; }
Property Value
Remarks
This is particularly useful in combination with nullable reference types, as it lets you safely access Data without a compiler warning.
IsError
True if the query threw an exception and has not been re-run.
bool IsError { get; }
Property Value
IsFetching
True if the query is currently running, either for the initial load or for subsequent fetches once the data is stale.
bool IsFetching { get; }
Property Value
Remarks
If you only need to know about the initial load, use IsLoading instead.
IsLoading
True if the query is currently loading and has not previously succeeded with the same argument.
bool IsLoading { get; }
Property Value
Remarks
This will return false
if the query is currently re-fetching in the background, and
already has data. Use IsFetching for these cases (e.g., to show a loading indicator).
IsSuccess
True if the query has succeeded.
bool IsSuccess { get; }
Property Value
Remarks
In many cases you should prefer to use HasData as it works better with nullable reference types.
IsUninitialized
True if no arguments have been provided to this query yet.
bool IsUninitialized { get; }
Property Value
Status
The current status of this query.
QueryStatus Status { get; }
Property Value
Methods
Cancel()
Cancels the currently running query, along with the CancellationToken that was passed to it.
void Cancel()
Remarks
If the query function does not use the CancellationToken, the query state will be reset, but the underlying operation will continue to run. You should not rely on this to cancel operations with side effects.
Detach()
Stop listening to changes of the current query. This allows the query data to be garbage
collected after the CacheTime
has passed (if there are no other observers for the
same Arg
).
void Detach()
Events
StateChanged
An event that fires whenever the state of this query changes.
event Action StateChanged