Extracts header paging information into the $page
and $pageCount
properties.
Usage:
Just add mixin to a model's mixin chain
var Bike = restmod.model('api/bikes', 'PagedModel');
Then using fetch on a collection bound to a paged api should provide page information
Bike.$search().$then(function() {
console.log this.$page; // should print the current page number.
console.log this.$pageCount; // should print the request total page count.
});
Paging information is extracted from the 'X-Page' and the 'X-Page-Total' headers, to use different headers just override the $pageHeader or the $pageCountHeader definition during model building.
restmod.model('PagedModel', function() {
this.define('$pageHeader', 'X-My-Page-Header');
})
- Source:
- plugins/paged.js, line 1