-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.umd.js
100 lines (82 loc) · 3.05 KB
/
index.umd.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
(factory((global.reduxBundlerReact = {}),global.react));
}(this, (function (exports,react) {
var CONTEXT_TYPES = {
store: function () {}
};
var Provider = /*@__PURE__*/(function (Component) {
function Provider () {
Component.apply(this, arguments);
}
if ( Component ) Provider.__proto__ = Component;
Provider.prototype = Object.create( Component && Component.prototype );
Provider.prototype.constructor = Provider;
Provider.prototype.getChildContext = function getChildContext () {
return {
store: this.props.store
};
};
Provider.prototype.render = function render () {
return react.Children.only(this.props.children);
};
return Provider;
}(react.Component));
Provider.childContextTypes = CONTEXT_TYPES;
var connect = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var Comp = args.slice(-1)[0];
var strings = args.length > 1 ? args.slice(0, -1) : [];
var actionCreators = [];
var keysToWatch = [];
strings.forEach(function (str) {
if (str.slice(0, 6) === 'select') {
keysToWatch.push(str);
return;
}
if (str.slice(0, 2) === 'do') {
actionCreators.push(str);
return;
}
throw Error(("CanNotConnect " + str));
});
var Connect = /*@__PURE__*/(function (Component) {
function Connect(props, context) {
var this$1 = this;
Component.call(this, props, context);
var store = context.store;
this.state = store.select(keysToWatch);
this.unsubscribe = store.subscribeToSelectors(keysToWatch, this.setState.bind(this));
this.actionCreators = {};
actionCreators.forEach(function (name) {
this$1.actionCreators[name] = function () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
if (store.action) {
return store.action(name, args);
}
return store[name].apply(store, args);
};
});
}
if ( Component ) Connect.__proto__ = Component;
Connect.prototype = Object.create( Component && Component.prototype );
Connect.prototype.constructor = Connect;
Connect.prototype.componentWillUnmount = function componentWillUnmount () {
this.unsubscribe();
};
Connect.prototype.render = function render () {
return react.createElement(Comp, Object.assign({}, this.props, this.state, this.actionCreators));
};
return Connect;
}(react.Component));
Connect.contextTypes = CONTEXT_TYPES;
Connect.displayName = 'connect(' + (Comp.displayName || Comp.name) + ')';
return Connect;
};
exports.Provider = Provider;
exports.connect = connect;
})));
//# sourceMappingURL=index.umd.js.map