emberjs/data — pull request #1517 by aexmachina (2013-11-19 19:52:24+00:00)
Title: Pagination

This PR adds the foundation for pagination support in Ember Data. Example usage using an 'infinite-scroll' `loadMore` approach can be [seen here](http://emberjs.jsbin.com/opakeBuJ/8/edit). The goal of this PR is to provide the underlying requirements to support pagination, so that the community can iterate on rest of the implementation in userland until we've got something we're happy with.

The solution adds a `DS.Request` class to contain information about the parameters that were used to create a given `AdapterPopulatedArray`, thereby allowing for more pages of results to be fetched from the server.

I've folded the `sinceToken` into the `Request` class, but this is the only 'breaking' change. So `Adapter.findAll: function(store, type, sinceToken)` is now `Adapter.findAll: function(store, type, request)`.

Please feel free to offer any feedback - I've tried to stay close to the style of the rest of the project, but happy to take on board any feedback.

One possible concern is that I'm using `page` and `pageSize` parameters which is nice and simple but there's an edge case where the `pageSize` changes and leads to duplicate/missing records in the series of pages. I'd prefer to use `offset` and `limit`, but the common practice seems to be `page` and `pageSize` so I've used this approach instead.

# Todo

- Currently only `findQuery()` and `findAll()` support pagination, I'll add support for the other `find...()` methods now
- Tests, I wanted to get this PR submitted so people can provide feedback as soon as possible and I'll get onto writing the specs now. These will be added to this PR shortly.