Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 613 Bytes

readme.md

File metadata and controls

31 lines (25 loc) · 613 Bytes

Redux debouncer

Install

yarn add redux-debouncer

How to use

import { makeReduxDebouncer } from 'redux-debouncer'

/**
 * type: string,
 * interval:? number,
 * compare:? (currentAction: any, prevAction: any) => bool,
 */
const incrementDebounce = makeReduxDebouncer({ type: 'increment' })

const middleware = [
  /* your middleware */
  incrementDebounce
]

Example

  // debouncer for react navigator
  export const reactNavigationDebounce = makeReduxDebouncer({
    type: 'Navigation/NAVIGATE',
    compare: (current, prev) => current.routeName === prev.routeName,
  })