fetchPagesAsFlow

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
}

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.