( actionCreators: ActionCreator<any> | ActionCreatorsMapObject, dispatch: Dispatch )
| 52 | >(actionCreators: M, dispatch: Dispatch): N |
| 53 | |
| 54 | export default function bindActionCreators( |
| 55 | actionCreators: ActionCreator<any> | ActionCreatorsMapObject, |
| 56 | dispatch: Dispatch |
| 57 | ) { |
| 58 | if (typeof actionCreators === 'function') { |
| 59 | return bindActionCreator(actionCreators, dispatch) |
| 60 | } |
| 61 | |
| 62 | if (typeof actionCreators !== 'object' || actionCreators === null) { |
| 63 | throw new Error( |
| 64 | `bindActionCreators expected an object or a function, but instead received: '${kindOf( |
| 65 | actionCreators |
| 66 | )}'. ` + |
| 67 | `Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?` |
| 68 | ) |
| 69 | } |
| 70 | |
| 71 | const boundActionCreators: ActionCreatorsMapObject = {} |
| 72 | for (const key in actionCreators) { |
| 73 | const actionCreator = actionCreators[key] |
| 74 | if (typeof actionCreator === 'function') { |
| 75 | boundActionCreators[key] = bindActionCreator(actionCreator, dispatch) |
| 76 | } |
| 77 | } |
| 78 | return boundActionCreators |
| 79 | } |
no test coverage detected