MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / bindActionCreators

Function bindActionCreators

code/redux/public/app.js:21205–21224  ·  view source on GitHub ↗

* Turns an object whose values are action creators, into an object with the * same keys, but with every function wrapped into a `dispatch` call so they * may be invoked directly. This is just a convenience method, as you can call * `store.dispatch(MyActionCreators.doSomething())` yourself just fi

(actionCreators, dispatch)

Source from the content-addressed store, hash-verified

21203 * function.
21204 */
21205function bindActionCreators(actionCreators, dispatch) {
21206 if (typeof actionCreators === 'function') {
21207 return bindActionCreator(actionCreators, dispatch);
21208 }
21209
21210 if (typeof actionCreators !== 'object' || actionCreators === null) {
21211 throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
21212 }
21213
21214 var keys = Object.keys(actionCreators);
21215 var boundActionCreators = {};
21216 for (var i = 0; i < keys.length; i++) {
21217 var key = keys[i];
21218 var actionCreator = actionCreators[key];
21219 if (typeof actionCreator === 'function') {
21220 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
21221 }
21222 }
21223 return boundActionCreators;
21224}
21225},{}],57:[function(require,module,exports){
21226(function (process){
21227'use strict';

Callers

nothing calls this directly

Calls 1

bindActionCreatorFunction · 0.85

Tested by

no test coverage detected