Gives every paged list of the app the same loading. Every list the API pages goes through useLoadMore for its next pages, and a list that loads on its own through usePagedList, from its first page on.

Functions

f
useLoadMore<T>(
list: PagedList<T> | null,
setList: (fn: (list: PagedList<T>) => PagedList<T>) => void,
fetchPage: FetchPage<T>
): () => void

Returns the call that loads the page after list's last one and appends it through setList. It does nothing unless canLoadMore(list); a page that fails leaves the list as it was, for the next call to try again. A page that loads its list along with more, as the search page does, uses it directly, and usePagedList for the others.

f
usePagedList<T extends { id: string; }>(
key: string | undefined,
fetchPage: FetchPage<T>,
cached?: Omit<FeedCacheEntry<T>, "savedAt"> | null
): UsePagedListResult<T>

Returns the list fetchPage serves for key, from its first page, and the call that loads the next. key changes as useFetchState's does, and cached, useFeedCache's restored list for it, if any, is shown without loading. The index's feeds, the profile's lists, the notifications and the popover of voters and likers use it.

Interfaces

I
UsePagedListResult

Returned by usePagedList.

Type Aliases

T
FetchPage<T> = (
page: number,
signal?: AbortSignal
) => Promise<PaginatedData<T>>

Passed to useLoadMore and usePagedList by a list's page or hook. It resolves to page page of the list, its items deserialized, as fetch with pageUrl and readPage gives it, and rejects when the page can't be had.