How to retrieve all values from the first API call using `paginateChunkEffect` in Effect Typescript

Good morning! I'm using paginateChunkEffect to paginate API result. Is there a way to get ALL values returned by the first API call? Right now, I'm only able to get individual value in the Chunk, instead of all values

I'm using the following code:

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
    )
  ))


And consuming it with:

Stream.runForEach(streamPages, (n) => Effect.log(n))
Was this page helpful?