2.0.3 • Published 7 years ago

redux-middleware-debounce v2.0.3

Weekly downloads
30
License
MIT
Repository
github
Last release
7 years ago

redux-middleware-debounce

Build Status npm

FSA-compliant middleware for Redux to debounce actions. Based on redux-debounce

Installation

$ npm install --save redux-middleware-debounce

Usage

Simply add a debounce property to any Flux Standard Action (or any object-based action) like so:

// Store setup
import { applyMiddleware, createStore } from 'redux'
import debounce from 'redux-middleware-debounce'
import createLogger from 'redux-logger'
import promise from 'redux-promise'
import thunk from 'redux-thunk'

const logger = createLogger()
const createMiddleware = applyMiddleware(debounce)
const store = createMiddleware(createStore)(reducer)

const debounceAction = () => ({
  type: 'TEST',
  debounce: {
    wait: 100
  },
})

Debounce middleware should be placed near the top of the chain, that way the debounce property will be stripped in time for other middlewares that validate, such as redux-api-middleware

Options

All Lodash debounce() options are supported:

See lodash

const debounceAction = () => ({
  type: 'TEST',
  debounce: {
    wait: 100,
    options: {
      maxWait: 1000
    }
  },
})

License

Copyright © 2016 Committed Software

Original examples and test code Copyright © 2015-2016 Neil Kistner. Released under the MIT license. See license for details.

2.0.3

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago