mapDispatchToProps.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
  3. exports.__esModule = true;
  4. exports["default"] = void 0;
  5. exports.whenMapDispatchToPropsIsFunction = whenMapDispatchToPropsIsFunction;
  6. exports.whenMapDispatchToPropsIsMissing = whenMapDispatchToPropsIsMissing;
  7. exports.whenMapDispatchToPropsIsObject = whenMapDispatchToPropsIsObject;
  8. var _bindActionCreators = _interopRequireDefault(require("../utils/bindActionCreators"));
  9. var _wrapMapToProps = require("./wrapMapToProps");
  10. function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
  11. return typeof mapDispatchToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapDispatchToProps, 'mapDispatchToProps') : undefined;
  12. }
  13. function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
  14. return !mapDispatchToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
  15. return {
  16. dispatch: dispatch
  17. };
  18. }) : undefined;
  19. }
  20. function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
  21. return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
  22. return (0, _bindActionCreators["default"])(mapDispatchToProps, dispatch);
  23. }) : undefined;
  24. }
  25. var _default = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
  26. exports["default"] = _default;