ampersand-pagination-mixin

0.1.0 • Public • Published

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

/ampersand-pagination-mixin/

    Package Sidebar

    Install

    npm i ampersand-pagination-mixin

    Weekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • jgantunes