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

Adds support for paged query arrays #41

Merged
merged 6 commits into from Sep 27, 2016

Conversation

Projects
None yet
3 participants
@burrows
Copy link
Member

burrows commented Sep 26, 2016

This PR enhances the Model.buildQuery method to return an array that is capable of paging itself. A paged array is a sparse array that knows its full length, but does not yet have all of its elements. When an element is accessed via the #at method that the array does not yet have it will automatically go to the mapper to fetch the page the contains that element index. When the mapper resolves its promise with the next page of results, those items are spliced into the array at the appropriate index instead of replacing the contents like a normal query array.

This strategy is designed to work nicely with a virtualized list component. You start by loading the first page of results and then hand that array to the virtualized list component. The virtualized list will only access enough items to fill its viewport, therefore not triggering any additional page loads until the next page of items is scrolled into view by the user. This makes it straightforward to implement a lazily loaded list view.

@burrows

This comment has been minimized.

Copy link
Member

burrows commented Sep 26, 2016

@peterwmwong @alexraginskiy Please take a look.

@burrows burrows merged commit f80109e into master Sep 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment