redux-throttle
Redux middleware to throttle your actions
npm install --save redux-throttle
Usage
;;;; const defaultWait = 300const defaultThrottleOption = // https://lodash.com/docs#throttle leading: true trailing: true const middleware = ;const store = createStorereducers;
Then you just have to dispatch actions with the meta throttle
:
type: 'ACTION_TYPE' meta: throttle: true type: 'ACTION_TYPE_2' meta: throttle: 300 // wait time type: 'ACTION_TYPE_3' meta: throttle: wait: 300 leading: false
There are 2 special actions exported by the library:
;
Both of them can be used to respectively cancel or flush a throttled action.
License
MIT