How to use the ember-infinity/lib/infinity-model.create function in ember-infinity

To help you get started, we’ve selected a few ember-infinity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ember-infinity / ember-infinity / addon / services / infinity.js View on Github external
const currentPage = options.startingPage === undefined ? 0 : options.startingPage - 1;
    // sets first page when route is loaded
    const firstPage = currentPage === 0 ? 1 : currentPage + 1;
    // chunk requests by indicated perPage param
    const perPage = options.perPage || 25;

    // store service methods (defaults to ember-data if nothing passed)
    const store = options.store || get(this, 'store');
    const storeFindMethod = options.storeFindMethod || 'query';

    let infinityModel;
    if (ExtendedInfinityModel) {
      // if custom InfinityModel, then use as base for creating an instance
      infinityModel = ExtendedInfinityModel.create();
    } else {
      infinityModel = InfinityModel.create();
    }

    // check if user passed in param w/ infinityModel, else default
    const perPageParam = paramsCheck('perPageParam', options, infinityModel);
    const pageParam = paramsCheck('pageParam', options, infinityModel);
    const totalPagesParam = paramsCheck('totalPagesParam', options, infinityModel);
    const countParam = paramsCheck('countParam', options, infinityModel);
    const infinityCache = paramsCheck('infinityCache', options, infinityModel);

    // create identifier for use in storing unique cached infinity model
    let identifier = stringifyObjectValues(options);

    delete options.startingPage;
    delete options.perPage;
    delete options.perPageParam;
    delete options.pageParam;

ember-infinity

Simple, flexible infinite scroll for Ember CLI Apps.

MIT
Latest version published 1 month ago

Package Health Score

78 / 100
Full package analysis