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

Function createConnect

code/redux/public/app.js:19042–19097  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19040// createConnect with default args builds the 'official' connect behavior. Calling it with
19041// different options opens up some testing and extensibility scenarios
19042function createConnect() {
19043 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
19044 _ref$connectHOC = _ref.connectHOC,
19045 connectHOC = _ref$connectHOC === undefined ? _connectAdvanced2.default : _ref$connectHOC,
19046 _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
19047 mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? _mapStateToProps2.default : _ref$mapStateToPropsF,
19048 _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
19049 mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? _mapDispatchToProps2.default : _ref$mapDispatchToPro,
19050 _ref$mergePropsFactor = _ref.mergePropsFactories,
19051 mergePropsFactories = _ref$mergePropsFactor === undefined ? _mergeProps2.default : _ref$mergePropsFactor,
19052 _ref$selectorFactory = _ref.selectorFactory,
19053 selectorFactory = _ref$selectorFactory === undefined ? _selectorFactory2.default : _ref$selectorFactory;
19054
19055 return function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
19056 var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
19057 _ref2$pure = _ref2.pure,
19058 pure = _ref2$pure === undefined ? true : _ref2$pure,
19059 _ref2$areStatesEqual = _ref2.areStatesEqual,
19060 areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual,
19061 _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual,
19062 areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? _shallowEqual2.default : _ref2$areOwnPropsEqua,
19063 _ref2$areStatePropsEq = _ref2.areStatePropsEqual,
19064 areStatePropsEqual = _ref2$areStatePropsEq === undefined ? _shallowEqual2.default : _ref2$areStatePropsEq,
19065 _ref2$areMergedPropsE = _ref2.areMergedPropsEqual,
19066 areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? _shallowEqual2.default : _ref2$areMergedPropsE,
19067 extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']);
19068
19069 var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
19070 var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
19071 var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
19072
19073 return connectHOC(selectorFactory, _extends({
19074 // used in error messages
19075 methodName: 'connect',
19076
19077 // used to compute Connect's displayName from the wrapped component's displayName.
19078 getDisplayName: function getDisplayName(name) {
19079 return 'Connect(' + name + ')';
19080 },
19081
19082 // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
19083 shouldHandleStateChanges: Boolean(mapStateToProps),
19084
19085 // passed through to selectorFactory
19086 initMapStateToProps: initMapStateToProps,
19087 initMapDispatchToProps: initMapDispatchToProps,
19088 initMergeProps: initMergeProps,
19089 pure: pure,
19090 areStatesEqual: areStatesEqual,
19091 areOwnPropsEqual: areOwnPropsEqual,
19092 areStatePropsEqual: areStatePropsEqual,
19093 areMergedPropsEqual: areMergedPropsEqual
19094
19095 }, extraOptions));
19096 };
19097}
19098
19099exports.default = createConnect();

Callers 1

app.jsFile · 0.85

Calls 2

_objectWithoutPropertiesFunction · 0.85
matchFunction · 0.85

Tested by

no test coverage detected