redux-page
v1.1.0
Published
action/reducer combo to assist with paging against a restful data source
Downloads
15
Readme
redux-page
action/reducer combo to assist with paging against a restful data source
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() {/* */} }