react-use-circuit-breaker
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

react-use-circuit-breaker

React hook that works like circuit breaker.

NPM JavaScript Style Guide Node.js CI semantic-release

Install

npm install --save react-use-circuit-breaker

Usage

import { useCircuitBreaker } from 'react-use-circuit-breaker'

/**
 * Execute callback function that passed by third argument
 * when send function called 2 times in 5 seconds.
 */
const [send] = useCircuitBreaker(2, 5000, () => {
  throw new Error("The breaker trips!");
});

send();
send();
send(); // => Uncaught Error: The breaker trips!

License

MIT © h-tachikawa


This hook is created using create-react-hook.

/react-use-circuit-breaker/

    Package Sidebar

    Install

    npm i react-use-circuit-breaker

    Weekly Downloads

    32

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    1.34 MB

    Total Files

    28

    Last publish

    Collaborators

    • h-tachikawa