Skip to content

[Feature] Pagination helper #798

@Neztore

Description

@Neztore

I have included some thoughts here of how it could be implemented, but it is very much open to discussion.

  • It could implement the async iterator protocol where each call to obj.next() will return a promise and the value (i.e. for a logs iterator it would return a specific log - not a page of logs)
  • Include a getAll method that iterates until all pages have been fetched and returns them as a single array (?) or exposes them through the normal iteration system
  • If we implement a standard way of doing this it would allow users to loop over results with ease while hiding the underlying complexity of fetching pages
  • (But that may encourage bad patterns? People looping over all results not realising it is making many requests?)
  • This would be a breaking change if we drop it in. Could we make it default to returning an array and allow a special parameter to return iterators? Or we could make it part of the v5 and replace it - but it is an increase in complexity to understand these iterators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions