fetchPagesAsFlow
inline fun <REQ : JsonRpcRequest, RES : PaginatedResult, ITEMS> fetchPagesAsFlow(endpoint: PaginatedEndpoint<REQ, RES, ITEMS>): Flow<ITEMS>
Repeatedly calls a paginated endpoint, emitting one set of ITEMS per page until PaginatedResult.nextCursor is null or an error is thrown.
Usage:
// Example: Fetch all prompt pages
val allPrompts = mutableListOf<Prompt>()
client.fetchPagesAsFlow(ListPromptsRequest)
.collect { prompts ->
println("Received page with ${prompts.size} prompts")
allPrompts += prompts
}Content copied to clipboard
In practice, endpoint can be one of the following:
Return
A Flow that emits one ITEMS instance per page.
Parameters
endpoint
A PaginatedEndpoint describing how to build requests and transform results.