diff --git a/dist/alt-with-addons.js b/dist/alt-with-addons.js index 756dffb8..769f7fa3 100644 --- a/dist/alt-with-addons.js +++ b/dist/alt-with-addons.js @@ -4,6 +4,7 @@ module.exports = require('./components/AltContainer.js'); },{"./components/AltContainer.js":2}],2:[function(require,module,exports){ +(function (global){ /** * AltContainer. * @@ -62,7 +63,7 @@ module.exports = require('./components/AltContainer.js'); */ 'use strict'; -var React = (window.React); +var React = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null); var mixinContainer = require('./mixinContainer'); var assign = require('../utils/functions').assign; @@ -76,6 +77,7 @@ var AltContainer = React.createClass(assign({ module.exports = AltContainer; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"../utils/functions":27,"./mixinContainer":3}],3:[function(require,module,exports){ 'use strict'; @@ -1496,6 +1498,7 @@ var AltStore = (function () { }, { key: 'unlisten', value: function unlisten(cb) { + if (!cb) throw new TypeError('Unlisten must receive a function'); this[Sym.LIFECYCLE].emit('unlisten'); this[EE].removeListener('change', cb); } @@ -1958,7 +1961,6 @@ var STATE_CONTAINER = (0, _esSymbol2['default'])(); exports.STATE_CONTAINER = STATE_CONTAINER; },{"es-symbol":5}],16:[function(require,module,exports){ -/* istanbul ignore next */ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -1969,6 +1971,7 @@ exports.warn = warn; exports.uid = uid; exports.formatAsConstant = formatAsConstant; exports.dispatchIdentity = dispatchIdentity; +/* istanbul ignore next */ function NoopClass() {} var builtIns = Object.getOwnPropertyNames(NoopClass); @@ -2162,6 +2165,16 @@ exports['default'] = ActionListeners; module.exports = exports['default']; },{"es-symbol":5}],19:[function(require,module,exports){ +'use strict'; + +Object.defineProperty(exports, '__esModule', { + value: true +}); + +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + /** * AltManager(Alt: AltClass): undefined * @@ -2188,16 +2201,6 @@ module.exports = exports['default']; * ``` */ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } - var AltManager = (function () { function AltManager(Alt) { _classCallCheck(this, AltManager); @@ -2493,12 +2496,12 @@ function atomic(alt) { module.exports = exports['default']; },{"./functions":24,"./makeFinalStore":25}],22:[function(require,module,exports){ -/*global window*/ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); +/*global window*/ exports['default'] = chromeDebug; function chromeDebug(alt) { @@ -2509,6 +2512,7 @@ function chromeDebug(alt) { module.exports = exports['default']; },{}],23:[function(require,module,exports){ +(function (global){ /** * 'Higher Order Component' that controls the props of a wrapped * component via stores. @@ -2562,7 +2566,7 @@ Object.defineProperty(exports, '__esModule', { function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var _react = (window.React); +var _react = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null); var _react2 = _interopRequireDefault(_react); @@ -2582,39 +2586,36 @@ function connectToStores(Component) { displayName: 'StoreConnection', getInitialState: function getInitialState() { - return Component.getPropsFromStores(this.props); + return Component.getPropsFromStores(this.props, this.context); }, componentDidMount: function componentDidMount() { var _this = this; - var stores = Component.getStores(this.props); + var stores = Component.getStores(this.props, this.context); stores.forEach(function (store) { store.listen(_this.onChange); }); - var component = this.refs['connectToStores-component']; - if (typeof component.componentDidConnect === 'function') { - component.componentDidConnect(); + if (Component.componentDidConnect) { + Component.componentDidConnect(this.props, this.context); } }, componentWillUnmount: function componentWillUnmount() { var _this2 = this; - var stores = Component.getStores(this.props); + var stores = Component.getStores(this.props, this.context); stores.forEach(function (store) { store.unlisten(_this2.onChange); }); }, onChange: function onChange() { - this.setState(Component.getPropsFromStores(this.props)); + this.setState(Component.getPropsFromStores(this.props, this.context)); }, render: function render() { - return _react2['default'].createElement(Component, (0, _functions.assign)({ - ref: 'connectToStores-component' - }, this.props, this.state)); + return _react2['default'].createElement(Component, (0, _functions.assign)({}, this.props, this.state)); } }); @@ -2624,6 +2625,7 @@ function connectToStores(Component) { exports['default'] = connectToStores; module.exports = exports['default']; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./functions":24}],24:[function(require,module,exports){ 'use strict'; @@ -2658,6 +2660,12 @@ function assign(target) { } },{}],25:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = makeFinalStore; /** * makeFinalStore(alt: AltInstance): AltStore * @@ -2682,12 +2690,6 @@ function assign(target) { * ``` */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports["default"] = makeFinalStore; function FinalStore() { var _this = this; @@ -2710,6 +2712,7 @@ function makeFinalStore(alt) { module.exports = exports["default"]; },{}],26:[function(require,module,exports){ +(function (global){ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -2719,7 +2722,7 @@ exports['default'] = withAltContext; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var _react = (window.React); +var _react = (typeof window !== "undefined" ? window.React : typeof global !== "undefined" ? global.React : null); var _react2 = _interopRequireDefault(_react); @@ -2743,6 +2746,7 @@ function withAltContext(flux) { module.exports = exports['default']; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],27:[function(require,module,exports){ 'use strict'; diff --git a/dist/alt.js b/dist/alt.js index 2561f242..6e79bd03 100644 --- a/dist/alt.js +++ b/dist/alt.js @@ -909,6 +909,7 @@ var AltStore = (function () { }, { key: 'unlisten', value: function unlisten(cb) { + if (!cb) throw new TypeError('Unlisten must receive a function'); this[Sym.LIFECYCLE].emit('unlisten'); this[EE].removeListener('change', cb); } @@ -1371,7 +1372,6 @@ var STATE_CONTAINER = (0, _esSymbol2['default'])(); exports.STATE_CONTAINER = STATE_CONTAINER; },{"es-symbol":1}],11:[function(require,module,exports){ -/* istanbul ignore next */ 'use strict'; Object.defineProperty(exports, '__esModule', { @@ -1382,6 +1382,7 @@ exports.warn = warn; exports.uid = uid; exports.formatAsConstant = formatAsConstant; exports.dispatchIdentity = dispatchIdentity; +/* istanbul ignore next */ function NoopClass() {} var builtIns = Object.getOwnPropertyNames(NoopClass); diff --git a/src/utils/connectToStores.js b/src/utils/connectToStores.js index 9720adab..95933cb1 100644 --- a/src/utils/connectToStores.js +++ b/src/utils/connectToStores.js @@ -58,28 +58,28 @@ function connectToStores(Component) { // Wrapper Component. const StoreConnection = React.createClass({ getInitialState() { - return Component.getPropsFromStores(this.props) + return Component.getPropsFromStores(this.props, this.context) }, componentDidMount() { - const stores = Component.getStores(this.props) + const stores = Component.getStores(this.props, this.context) stores.forEach((store) => { store.listen(this.onChange) }) - if (Component.componentDidConnect !== undefined) { - Component.componentDidConnect(this.props) + if (Component.componentDidConnect) { + Component.componentDidConnect(this.props, this.context) } }, componentWillUnmount() { - const stores = Component.getStores(this.props) + const stores = Component.getStores(this.props, this.context) stores.forEach((store) => { store.unlisten(this.onChange) }) }, onChange() { - this.setState(Component.getPropsFromStores(this.props)) + this.setState(Component.getPropsFromStores(this.props, this.context)) }, render() {