Skip to content
This repository was archived by the owner on Jun 29, 2021. It is now read-only.

commitd/redux-middleware-debounce

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 { debounceMiddleware } 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(debounceMiddleware)
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: {
    key: 'uniqueKey',    
    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.

About

FSA and RSAA compliant middleware for Redux to debounce actions.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Languages

  • JavaScript 100.0%