redux-action-listener-hook

1.0.4 • Public • Published

Welcome to redux-action-listener-hook 👋

Version Documentation Maintenance License: MIT

Redux middleware hook which allows listening action and handling of dispatched actions

Usage

// 1. Register middleware
import { createMiddleware } from 'redux-action-listener-hook';

export const store = createStore(
  reduce,
  {},
  applyMiddleware(createMiddleware(), thunk)
);

// 2. use hook
import { useActionListener } from 'redux-action-listener-hook';

const onClickPlus = () => {
  // When button is clicked an action 'ADD' is dispatched.
  dispatch({ type: 'ADD' });
};

useActionListener('ADD', (dispatch, action) => {
  // Now you can listen 'ADD'
  // {"type":"ADD","payload":1}
  console.log(`${JSON.stringify(action)}`);
});

return <button onClick={onClickPlus}>add</button>;

Install

npm i redux-action-listener-hook

Links

Run tests

npm test

Author

👤 Jeong Hoon Park

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 Jeong Hoon Park.

This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Package Sidebar

Install

npm i redux-action-listener-hook

Weekly Downloads

40

Version

1.0.4

License

MIT

Unpacked Size

17.6 kB

Total Files

18

Last publish

Collaborators

  • qkreltms