New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

debounce-action

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debounce-action

Create a debounced Redux action

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
329
decreased by-24.71%
Maintainers
1
Weekly downloads
 
Created
Source

Debounce Action NPM version

Create debounced redux-thunk actions. Debounced actions will delay being dispatched until after wait milliseconds have elapsed since the last time the debounced action was dispatched.

Installation

npm i --save debounce-action

Usage

import debounceAction from 'debounce-action';

const INCREMENT_COUNTER = 'INCREMENT_COUNTER';

function increment() {
  return {
    type: INCREMENT_COUNTER
  };
}

function incrementThunk() {
  return dispatch => {
    dispatch(increment());
  };
}

// wrap normal actions with debounceAction() to create debounced actions
const incrementDebounced = debounceAction(increment, 1000);
const incrementThunkDebounced = debounceAction(incrementThunk, 5000, {leading: true});

// call debounced actions like normal redux actions
import {createStore, applyMiddleware} from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers';

const store = createStore(
  rootReducer,
  applyMiddleware(thunk)
);

store.dispatch(incrementDebounced());
store.dispatch(incrementDebounced());
// --> INCREMENT_COUNTER dispatched once after one second

store.dispatch(incrementThunkDebounced());
// --> INCREMENT_COUNTER dispatched immediately
store.dispatch(incrementThunkDebounced());
store.dispatch(incrementThunkDebounced());
// --> INCREMENT_COUNTER dispatched once again after five seconds

Uses lodash's debounce.

License

MIT

Keywords

FAQs

Package last updated on 22 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc