Code Monkey home page Code Monkey logo

Comments (3)

ogonkov avatar ogonkov commented on June 3, 2024

I think lib will expect to have actual models aswell, so beside having links for all pages, you probably need to generate (and then update) some stub models. I believe that lib just slice models from fullCollection, without actually fetching it.

if ((mode == "client" || (mode == "infinite" && !_isEmpty(pageModels))) &&
!options.fetch) {
this.reset(pageModels, _omit(options, "fetch"));
return this;
}

Links persistent checked few lines above

this.state = this._checkState(_extend({}, state, {currentPage: pageNum}));

I face the problem that i want reuse already fetched models, and having a paging, that means that i need to load pages from first to last sequentially, to prevent fullCollection break.

As a temporarily "fix" i have override getPage method to switch to server mode for initial fetch, but it will break, if next page would be >1 from the current (no link for it in state)

import PageableCollection from 'backbone.paginator';

export class Foo extends PageableCollection {
  getPage(index, options) {
    const useServerMode = (
      index > this.state.firstPage &&
      this.length === 0 &&
      this.mode === 'infinite'
    );

    if (useServerMode) {
      const fetch = false; // Prevent unnecessary fetch while switching modes

      this.switchMode('server', {
        fetch
      });

      this.once('sync', function() {
        this.switchMode('infinite', {
          fetch
        });
      }, this);
    }

    return super.getPage(index, options)
  }
}

from backbone.paginator.

wyuenho avatar wyuenho commented on June 3, 2024

@ogonkov I've invited you as a collaborator of this repo. Since I don't use this library much anymore, it'd be nicer for someone who knows what's going on to help maintain it.

from backbone.paginator.

ogonkov avatar ogonkov commented on June 3, 2024

@wyuenho thank you

from backbone.paginator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.