Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to paginate #22

Open
NullVoxPopuli opened this issue Aug 5, 2021 · 0 comments
Open

Provide a way to paginate #22

NullVoxPopuli opened this issue Aug 5, 2021 · 0 comments

Comments

@NullVoxPopuli
Copy link
Owner

maybe:

@tracked page = 1;

currentPage = findAll(this, 'posts', () => ({ page: this.page /* i don't know how this works exactly, depends on api, I guess? */ }));
records = collectPages(this, () => ({ page: this.page, records: this.currentPage.records }));

collectPages would keep a map of page => records and the return records could contain a collection of all records.
if page is ever set to a page that's already been visited, the set for that page will be re-set -- so your total list of data doesn't go stale.

If you wanted to avoid that request, you'd maybe want to track visited pages separate from records pages, so you can cache that way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant