redux-page

1.1.0 • Public • Published

redux-page

action/reducer combo to assist with paging against a restful data source

styled with prettier XO code style

usage

  • uses redux-pack, so need to follow directions and add middleware

  • configure an instance with a promise based service that adheres to the following contract

    • input:
    {offset: 1, limit: 1, sort: {field: 'name', isAscending: true}, ...fieldFilters}

    fieldFilters (arbitrary name, just illustrating with spread operator above) are optional, but can contain resource specific filters like {lastName: 'smith'}

    • output:
    {data: [{}], total: 1, query: {/* just returns input argument */}}
  • obtain an instance of redux-page like below

    import config from 'config'
    import getRedux from 'redux-page'
    import {feathers} from 'web-helpr'
    import {openSnackbar} from '../layout/layout-redux'
    
    const url = config.api.url
    const resource = 'people'
    const index = feathers.getIndex({url, resource})
    export default getRedux({resource: 'people', index, limit: 3, onFailure: openSnackbar})
  • redux-page instance will be an object like below which can be used as in typical redux fashion:

    {
      actions: {
        //...
      },
      reducer: function() {/* */}
    }

Readme

Keywords

none

Package Sidebar

Install

npm i redux-page

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • tony-kerz