1.0.4 ā€¢ Published 3 years ago

redux-action-listener-hook v1.0.4

Weekly downloads
13
License
MIT
Repository
github
Last release
3 years ago

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