redux-debounce-listener
v0.0.1
Published
A proxy creator for Redux store to debounce listeners.
Downloads
4
Readme
Redux Debounce Listener
A proxy creator for Redux store to debounce listeners.
Motivation
Redux Debounce Listener allows you to delay invoking listeners. If you use this with React, rendering cost may be reduced.
Installation
npm install --save redux-debounce-listener
Example App
$ cd example
$ npm install
$ npm start
Examples of Use
Simple
import { createStore } from 'redux';
import debounceListener from 'redux-debounce-listener'
import rootReducer from './reducers/index';
// create a store that has redux-debounce-listener enabled
const finalCreateStore = debounceListener(50, { 'leading': true })(createStore);
const store = finalCreateStore(rootReducer);
Composition
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import debounceListener from 'redux-debounce-listener'
import rootReducer from './reducers/index';
// create a store that has redux-thunk middleware and dux-debounce-listener enabled
const finalCreateStore = compose(
applyMiddleware(thunk),
debounceListener(50, { 'leading': true })
)(createStore)
const store = finalCreateStore(rootReducer);
API
debounceListener([wait=0], [options])
wait
and options
parameters are passed to the lodash debounce function.
See debounce for details.
License
MIT