( actionCreators: ActionCreatorsMapObject, dispatch: Dispatch, )
| 1 | import type { ActionCreatorsMapObject, Dispatch } from 'redux' |
| 2 | |
| 3 | export default function bindActionCreators( |
| 4 | actionCreators: ActionCreatorsMapObject, |
| 5 | dispatch: Dispatch, |
| 6 | ): ActionCreatorsMapObject { |
| 7 | const boundActionCreators: ActionCreatorsMapObject = {} |
| 8 | |
| 9 | for (const key in actionCreators) { |
| 10 | const actionCreator = actionCreators[key] |
| 11 | if (typeof actionCreator === 'function') { |
| 12 | boundActionCreators[key] = (...args) => dispatch(actionCreator(...args)) |
| 13 | } |
| 14 | } |
| 15 | return boundActionCreators |
| 16 | } |
no test coverage detected
searching dependent graphs…