moderator-toolbox-nxg-for-reddit / api/transport/pagination
api/transport/pagination¶
Functions¶
fetchAllListingPages()¶
fetchAllListingPages<
T>(fetchPage,options?):Promise<T[]>
Defined in: extension/data/api/transport/pagination.ts:72
Fetches all pages from a Reddit listing endpoint using an after cursor,
collecting data.children across all pages into a single array.
Stops when the response has no after cursor, when a page returns no
children, or when options.maxCount items have been accumulated.
Type Parameters¶
T¶
T
Parameters¶
fetchPage¶
(after) => Promise<{ data: { after: string | null | undefined; children: T[]; }; }>
Called for each page; receives the after cursor from the
previous response (undefined on the first call) and must return a Reddit
listing response containing data.children and data.after.
options?¶
maxCount?¶
number
Stop after accumulating at least this many items.
maxRetries?¶
number
Maximum total attempts per page when a 504 Gateway Timeout is encountered. Defaults to 1 (first failure throws immediately).
Returns¶
Promise<T[]>
is504()¶
is504(
error):boolean
Defined in: extension/data/api/transport/pagination.ts:11
Reports whether a caught value represents a 504 Gateway Timeout response,
which callers may safely retry. Accepts any thrown value - only objects
carrying a response.status of 504 match - so it works for both
RequestError instances and plain {response: {status}} shapes. Defined
here (rather than in http) so it carries no browser-extension dependency.
Parameters¶
error¶
unknown
The caught value to inspect.
Returns¶
boolean
pageFromListing()¶
pageFromListing<
T>(envelope):Page<T>
Defined in: extension/data/api/transport/pagination.ts:51
Converts a Reddit REST listing envelope into a transport-neutral Page.
This is the single point where the REST envelope shape is unwrapped. Resource modules
call it so that data.children / data.after never reach feature code.
Type Parameters¶
T¶
T
Parameters¶
envelope¶
RestListingEnvelope<T>
The raw listing response.
Returns¶
Page<T>
Interfaces¶
Page¶
Defined in: extension/data/api/transport/pagination.ts:23
One page of a listing, decoupled from the transport’s envelope shape.
Feature code consumes this instead of the raw Reddit listing envelope
({kind: 'Listing', data: {children, after}}) so that paging semantics live in one
place rather than being re-derived at every call site.
Type Parameters¶
T¶
T
Properties¶
cursor¶
cursor:
string|null
Defined in: extension/data/api/transport/pagination.ts:33
Cursor for the next page, or null when the listing is exhausted.
Treat this as opaque: hand it back to the next fetch unchanged, and never parse,
compare, or construct one. Today it is a Reddit after fullname; the format is
owned by the transport and is not part of this contract.
items¶
items:
T[]
Defined in: extension/data/api/transport/pagination.ts:25
The items on this page, in the order the endpoint returned them.