const streamPages = Stream.paginateChunkEffect(0, (start) =>
pipe(
fetchPage(start),
Effect.tap(Effect.log("CALLING")),
Effect.map(
(response) =>
[
// first element of tuple is a Chunk of the elements
Chunk.fromIterable(response),
// second element is an Option of the next cursor
response.length === 0 ? Option.none<number>() : Option.some(start + 5)
] as const
)
))
const streamPages = Stream.paginateChunkEffect(0, (start) =>
pipe(
fetchPage(start),
Effect.tap(Effect.log("CALLING")),
Effect.map(
(response) =>
[
// first element of tuple is a Chunk of the elements
Chunk.fromIterable(response),
// second element is an Option of the next cursor
response.length === 0 ? Option.none<number>() : Option.some(start + 5)
] as const
)
))