Code Monkey home page Code Monkey logo

drf-paginator's People

Contributors

beck avatar devshep avatar eugeneford avatar morrisallison avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drf-paginator's Issues

Initial Implementation

The goal is to make pagination easier to deal with for our clients. Clients have request functions in the form of request(queryParams) that return a promise for the response.

Paginator Object

The paginator wraps a request and provides a clean API for returning promises for the results of each page.

  • new Paginator(request, queryParams): constructor that takes a request and query params for said request
  • paginator.next(): returns the next page.
    • Initial call should either be page 1 or the page given as a key on queryParams during initialization of the paginator.
    • Caches responses to prevent duplicate requests
  • paginator.previous(): returns the previous page
    • Functions much like next in that it will return cached responses or make new requests

Static methods:

  • Paginator.all(request, queryParams): returns a promise for all the pages of an endpoint concatenated together as a single result list

Add additional methods for more robust API for the paginator

While not needed for MVP, we'd like the paginator object to support the additional methods:

  • paginator.first(): returns the first page and sets the current page to the first one
  • paginator.last(): returns the last page and sets current page to it
  • paginator.current(): returns the current page, which should be the same promise that was last returned by next or previous.

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.