0.1.0 • Published 9 years ago

ampersand-pagination-mixin v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

js-semistandard-style Dependency Status devDependency Status

ampersand-pagination-mixin

A simple mixin to be used with ampersand collection to perform paginated requests. This module assumes you somehow implement a restful method collection.fetch() therefore being a perfect match to be used with ampersand-rest-collection. It works by inserting a skip and limit fields on the query component of the URI.

Example:

  var InfiniteScrollMixin = require('ampersand-pagination-mixin');
  var RestCollection = require('ampersand-rest-collection');
  var MyModel = require('./MyModel');

  var PaginatedCollection = RestCollection.extend(InfiniteScrollMixin, {
    model: MyModel,
    url: '/api/paginated-resource'
  });
  
  var myCollection = new PaginatedCollection();

  // Now just use the method and let it keep the state for you
  myCollection.fetchPage();

To use this collection with a infinite scroll view use ampersand-infinite-scroll as it works out of the box with it.

credits

Created by @JGAntunes, with the support of @SINFO.

license

MIT