Class InfiniteQueryState<TData, TPageParam>
- Namespace
- DotNetQuery.Core
- Assembly
- DotNetQuery.Core.dll
An immutable snapshot of an infinite query's current state. Use the static factory methods to create instances.
public sealed record InfiniteQueryState<TData, TPageParam> : IEquatable<InfiniteQueryState<TData, TPageParam>>
Type Parameters
TDataThe type of a single page of data.
TPageParamThe type of the page parameter (cursor/offset).
- Inheritance
-
InfiniteQueryState<TData, TPageParam>
- Implements
-
IEquatable<InfiniteQueryState<TData, TPageParam>>
- Inherited Members
Properties
Error
The exception from the most recent failed fetch. null when not in a failure state.
public Exception? Error { get; }
Property Value
HasData
true when at least one page has been successfully loaded.
public bool HasData { get; }
Property Value
HasError
true when Error is not null.
public bool HasError { get; }
Property Value
HasNextPage
true when a next page is available to fetch.
public bool HasNextPage { get; }
Property Value
HasPreviousPage
true when a previous page is available to fetch.
public bool HasPreviousPage { get; }
Property Value
IsFailure
public bool IsFailure { get; }
Property Value
IsFetching
public bool IsFetching { get; }
Property Value
IsFetchingNextPage
true while a FetchNextPage() is in progress.
Existing pages remain visible during this state.
public bool IsFetchingNextPage { get; }
Property Value
IsFetchingPreviousPage
true while a FetchPreviousPage() is in progress.
Existing pages remain visible during this state.
public bool IsFetchingPreviousPage { get; }
Property Value
IsIdle
public bool IsIdle { get; }
Property Value
IsSuccess
public bool IsSuccess { get; }
Property Value
PageParams
The page parameters used to fetch each page in Pages.
PageParams[i] was the parameter used to fetch Pages[i].
public IReadOnlyList<TPageParam> PageParams { get; }
Property Value
- IReadOnlyList<TPageParam>
Pages
All currently loaded pages, ordered from oldest to newest.
public IReadOnlyList<TData> Pages { get; }
Property Value
- IReadOnlyList<TData>
Status
The current lifecycle status of the query.
public QueryStatus Status { get; }
Property Value
Methods
CreateFailure(Exception, IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)
Creates a Failure state, preserving pages from the last successful fetch.
public static InfiniteQueryState<TData, TPageParam> CreateFailure(Exception error, IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)
Parameters
errorExceptionpagesIReadOnlyList<TData>pageParamsIReadOnlyList<TPageParam>hasNextPageboolhasPreviousPagebool
Returns
- InfiniteQueryState<TData, TPageParam>
CreateFetching(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)
Creates a Fetching state that carries existing pages for stale-while-revalidate display during a full refetch.
public static InfiniteQueryState<TData, TPageParam> CreateFetching(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)
Parameters
pagesIReadOnlyList<TData>pageParamsIReadOnlyList<TPageParam>hasNextPageboolhasPreviousPagebool
Returns
- InfiniteQueryState<TData, TPageParam>
CreateFetchingNext(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)
Creates a success state with IsFetchingNextPage set. Existing pages remain visible while the next page loads.
public static InfiniteQueryState<TData, TPageParam> CreateFetchingNext(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)
Parameters
pagesIReadOnlyList<TData>pageParamsIReadOnlyList<TPageParam>hasNextPageboolhasPreviousPagebool
Returns
- InfiniteQueryState<TData, TPageParam>
CreateFetchingPrevious(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)
Creates a success state with IsFetchingPreviousPage set. Existing pages remain visible while the previous page loads.
public static InfiniteQueryState<TData, TPageParam> CreateFetchingPrevious(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)
Parameters
pagesIReadOnlyList<TData>pageParamsIReadOnlyList<TPageParam>hasNextPageboolhasPreviousPagebool
Returns
- InfiniteQueryState<TData, TPageParam>
CreateIdle()
Creates an Idle state with no pages.
public static InfiniteQueryState<TData, TPageParam> CreateIdle()
Returns
- InfiniteQueryState<TData, TPageParam>
CreateSuccess(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)
Creates a settled Success state with the given pages.
public static InfiniteQueryState<TData, TPageParam> CreateSuccess(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)
Parameters
pagesIReadOnlyList<TData>pageParamsIReadOnlyList<TPageParam>hasNextPageboolhasPreviousPagebool
Returns
- InfiniteQueryState<TData, TPageParam>