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.
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.
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.
Returned by usePagedList.
-
loadMore: () => void
It goes to
useInfiniteScrollor to aLoadMoreButton. -
resync: () => void
Fetches again every page loaded so far and puts them in the list's place, keeping its length and so the scroll. The live lists call it on
useOnReconnect, for what changed while the socket was down. A page that fails leaves the list as it was. -
setItems: (fn: (items: T[]) => T[]) => void
Does nothing until loaded. Passed to the sync hooks.
- state: FetchState<PagedList<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.
Usage
import * as mod from "src/hooks/feed/usePagedList.ts";