redux-action-listener-hook
v1.0.4
Published
Redux middleware hook which allows listening action and handling of dispatched actions
Downloads
260
Maintainers
Readme
Welcome to redux-action-listener-hook 👋
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
- Motivation
- Video tutorial
- Examples
Run tests
npm test
Author
👤 Jeong Hoon Park
- Website: https://github.com/qkreltms
- Github: @qkreltms
🤝 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