Package Exports
- redux-action-listener-hook
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-action-listener-hook) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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