Comparing version 0.12.0 to 1.0.0-alpha
@@ -65,7 +65,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _index = __webpack_require__(13); | ||
var _index = __webpack_require__(15); | ||
_defaults(exports, _interopRequireWildcard(_index)); | ||
var _react = __webpack_require__(15); | ||
var _react = __webpack_require__(17); | ||
@@ -76,44 +76,2 @@ _defaults(exports, _interopRequireWildcard(_react)); | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = createDispatcher; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _utilsComposeMiddleware = __webpack_require__(2); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var INIT_ACTION = { | ||
type: '@@INIT' | ||
}; | ||
function createDispatcher(store) { | ||
var middlewares = arguments[1] === undefined ? [] : arguments[1]; | ||
return function dispatcher(initialState, setState) { | ||
var state = setState(store(initialState, INIT_ACTION)); | ||
function dispatch(action) { | ||
state = setState(store(state, action)); | ||
return action; | ||
} | ||
function getState() { | ||
return state; | ||
} | ||
var finalMiddlewares = typeof middlewares === 'function' ? middlewares(getState) : middlewares; | ||
return _utilsComposeMiddleware2['default'].apply(undefined, finalMiddlewares.concat([dispatch])); | ||
}; | ||
} | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
@@ -139,3 +97,3 @@ | ||
/***/ }, | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -146,22 +104,23 @@ | ||
exports.__esModule = true; | ||
exports['default'] = composeStores; | ||
exports['default'] = composeReducers; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _utilsMapValues = __webpack_require__(5); | ||
var _utilsMapValues = __webpack_require__(6); | ||
var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); | ||
var _utilsPick = __webpack_require__(19); | ||
var _utilsPick = __webpack_require__(20); | ||
var _utilsPick2 = _interopRequireDefault(_utilsPick); | ||
function composeStores(stores) { | ||
var finalStores = (0, _utilsPick2['default'])(stores, function (val) { | ||
function composeReducers(reducers) { | ||
var finalReducers = _utilsPick2['default'](reducers, function (val) { | ||
return typeof val === 'function'; | ||
}); | ||
return function Composition(atom, action) { | ||
if (atom === undefined) atom = {}; | ||
return (0, _utilsMapValues2['default'])(finalStores, function (store, key) { | ||
return _utilsMapValues2['default'](finalReducers, function (store, key) { | ||
return store(atom[key], action); | ||
@@ -175,2 +134,21 @@ }); | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = createStoreShape; | ||
function createStoreShape(PropTypes) { | ||
return PropTypes.shape({ | ||
subscribe: PropTypes.func.isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
getState: PropTypes.func.isRequired | ||
}); | ||
} | ||
module.exports = exports["default"]; | ||
/***/ }, | ||
/* 4 */ | ||
@@ -194,2 +172,17 @@ /***/ function(module, exports) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = isPlainObject; | ||
function isPlainObject(obj) { | ||
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false; | ||
} | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
@@ -210,7 +203,66 @@ | ||
/***/ }, | ||
/* 6 */ | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule invariant | ||
*/ | ||
'use strict'; | ||
/** | ||
* Use invariant() to assert state which your program assumes to be true. | ||
* | ||
* Provide sprintf-style format (only %s is supported) and arguments | ||
* to provide information about what broke and what you were | ||
* expecting. | ||
* | ||
* The invariant message will be stripped in production, but the invariant | ||
* will remain to ensure logic does not differ in production. | ||
*/ | ||
var invariant = function(condition, format, a, b, c, d, e, f) { | ||
if ((undefined) !== 'production') { | ||
if (format === undefined) { | ||
throw new Error('invariant requires an error message argument'); | ||
} | ||
} | ||
if (!condition) { | ||
var error; | ||
if (format === undefined) { | ||
error = new Error( | ||
'Minified exception occurred; use the non-minified dev environment ' + | ||
'for the full error message and additional helpful warnings.' | ||
); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
error = new Error( | ||
'Invariant Violation: ' + | ||
format.replace(/%s/g, function() { return args[argIndex++]; }) | ||
); | ||
} | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
}; | ||
module.exports = invariant; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
@@ -222,57 +274,47 @@ | ||
var _createDispatcher = __webpack_require__(1); | ||
var _invariant = __webpack_require__(7); | ||
var _createDispatcher2 = _interopRequireDefault(_createDispatcher); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _utilsComposeStores = __webpack_require__(3); | ||
var _utilsIsPlainObject = __webpack_require__(5); | ||
var _utilsComposeStores2 = _interopRequireDefault(_utilsComposeStores); | ||
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); | ||
var _middlewareThunk = __webpack_require__(14); | ||
var Store = (function () { | ||
function Store(reducer, initialState) { | ||
_classCallCheck(this, Store); | ||
var _middlewareThunk2 = _interopRequireDefault(_middlewareThunk); | ||
_invariant2['default'](typeof reducer === 'function', 'Expected the reducer to be a function.'); | ||
var Redux = (function () { | ||
function Redux(dispatcher, initialState) { | ||
_classCallCheck(this, Redux); | ||
var finalDispatcher = dispatcher; | ||
if (typeof dispatcher === 'object') { | ||
// A shortcut notation to use the default dispatcher | ||
finalDispatcher = (0, _createDispatcher2['default'])((0, _utilsComposeStores2['default'])(dispatcher), function (getState) { | ||
return [(0, _middlewareThunk2['default'])(getState)]; | ||
}); | ||
} | ||
this.state = initialState; | ||
this.listeners = []; | ||
this.replaceDispatcher(finalDispatcher); | ||
this.replaceReducer(reducer); | ||
} | ||
Redux.prototype.getDispatcher = function getDispatcher() { | ||
return this.dispatcher; | ||
Store.prototype.getReducer = function getReducer() { | ||
return this.reducer; | ||
}; | ||
Redux.prototype.replaceDispatcher = function replaceDispatcher(nextDispatcher) { | ||
this.dispatcher = nextDispatcher; | ||
this.dispatchFn = nextDispatcher(this.state, this.setState.bind(this)); | ||
Store.prototype.replaceReducer = function replaceReducer(nextReducer) { | ||
this.reducer = nextReducer; | ||
this.dispatch({ type: '@@INIT' }); | ||
}; | ||
Redux.prototype.dispatch = function dispatch(action) { | ||
return this.dispatchFn(action); | ||
}; | ||
Store.prototype.dispatch = function dispatch(action) { | ||
_invariant2['default'](_utilsIsPlainObject2['default'](action), 'Actions must be plain objects. Use custom middleware for async actions.'); | ||
Redux.prototype.getState = function getState() { | ||
return this.state; | ||
}; | ||
var reducer = this.reducer; | ||
Redux.prototype.setState = function setState(nextState) { | ||
this.state = nextState; | ||
this.state = reducer(this.state, action); | ||
this.listeners.forEach(function (listener) { | ||
return listener(); | ||
}); | ||
return nextState; | ||
return action; | ||
}; | ||
Redux.prototype.subscribe = function subscribe(listener) { | ||
Store.prototype.getState = function getState() { | ||
return this.state; | ||
}; | ||
Store.prototype.subscribe = function subscribe(listener) { | ||
var listeners = this.listeners; | ||
@@ -288,10 +330,10 @@ | ||
return Redux; | ||
return Store; | ||
})(); | ||
exports['default'] = Redux; | ||
exports['default'] = Store; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 7 */ | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -306,15 +348,15 @@ | ||
var _createProvider = __webpack_require__(11); | ||
var _createProvider = __webpack_require__(13); | ||
var _createProvider2 = _interopRequireDefault(_createProvider); | ||
var _createProvideDecorator = __webpack_require__(10); | ||
var _createProvideDecorator = __webpack_require__(12); | ||
var _createProvideDecorator2 = _interopRequireDefault(_createProvideDecorator); | ||
var _createConnector = __webpack_require__(9); | ||
var _createConnector = __webpack_require__(11); | ||
var _createConnector2 = _interopRequireDefault(_createConnector); | ||
var _createConnectDecorator = __webpack_require__(8); | ||
var _createConnectDecorator = __webpack_require__(10); | ||
@@ -325,8 +367,8 @@ var _createConnectDecorator2 = _interopRequireDefault(_createConnectDecorator); | ||
// Wrapper components | ||
var Provider = (0, _createProvider2['default'])(React); | ||
var Connector = (0, _createConnector2['default'])(React); | ||
var Provider = _createProvider2['default'](React); | ||
var Connector = _createConnector2['default'](React); | ||
// Higher-order components (decorators) | ||
var provide = (0, _createProvideDecorator2['default'])(React, Provider); | ||
var connect = (0, _createConnectDecorator2['default'])(React, Connector); | ||
var provide = _createProvideDecorator2['default'](React, Provider); | ||
var connect = _createConnectDecorator2['default'](React, Connector); | ||
@@ -339,3 +381,3 @@ return { Provider: Provider, Connector: Connector, provide: provide, connect: connect }; | ||
/***/ }, | ||
/* 8 */ | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -363,3 +405,3 @@ | ||
var _utilsShallowEqualScalar = __webpack_require__(21); | ||
var _utilsShallowEqualScalar = __webpack_require__(22); | ||
@@ -377,5 +419,3 @@ var _utilsShallowEqualScalar2 = _interopRequireDefault(_utilsShallowEqualScalar); | ||
if (_Component != null) { | ||
_Component.apply(this, arguments); | ||
} | ||
_Component.apply(this, arguments); | ||
} | ||
@@ -386,3 +426,3 @@ | ||
ConnectorDecorator.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { | ||
return !(0, _utilsShallowEqualScalar2['default'])(this.props, nextProps); | ||
return !_utilsShallowEqualScalar2['default'](this.props, nextProps); | ||
}; | ||
@@ -406,3 +446,3 @@ | ||
key: 'displayName', | ||
value: 'Connector(' + (0, _utilsGetDisplayName2['default'])(DecoratedComponent) + ')', | ||
value: 'Connector(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')', | ||
enumerable: true | ||
@@ -424,3 +464,3 @@ }, { | ||
/***/ }, | ||
/* 9 */ | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -444,15 +484,19 @@ | ||
var _utilsIdentity = __webpack_require__(17); | ||
var _utilsCreateStoreShape = __webpack_require__(3); | ||
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape); | ||
var _utilsIdentity = __webpack_require__(19); | ||
var _utilsIdentity2 = _interopRequireDefault(_utilsIdentity); | ||
var _utilsShallowEqual = __webpack_require__(20); | ||
var _utilsShallowEqual = __webpack_require__(21); | ||
var _utilsShallowEqual2 = _interopRequireDefault(_utilsShallowEqual); | ||
var _utilsIsPlainObject = __webpack_require__(18); | ||
var _utilsIsPlainObject = __webpack_require__(5); | ||
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); | ||
var _invariant = __webpack_require__(22); | ||
var _invariant = __webpack_require__(7); | ||
@@ -465,2 +509,4 @@ var _invariant2 = _interopRequireDefault(_invariant); | ||
var storeShape = _utilsCreateStoreShape2['default'](PropTypes); | ||
return (function (_Component) { | ||
@@ -471,4 +517,2 @@ function Connector(props, context) { | ||
_Component.call(this, props, context); | ||
this.unsubscribe = context.redux.subscribe(this.handleChange.bind(this)); | ||
this.state = this.selectState(props, context); | ||
@@ -480,3 +524,3 @@ } | ||
Connector.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { | ||
return !this.isSliceEqual(this.state.slice, nextState.slice) || !(0, _utilsShallowEqual2['default'])(this.props, nextProps); | ||
return !this.isSliceEqual(this.state.slice, nextState.slice) || !_utilsShallowEqual2['default'](this.props, nextProps); | ||
}; | ||
@@ -491,5 +535,9 @@ | ||
} | ||
return (0, _utilsShallowEqual2['default'])(slice, nextSlice); | ||
return _utilsShallowEqual2['default'](slice, nextSlice); | ||
}; | ||
Connector.prototype.componentDidMount = function componentDidMount() { | ||
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this)); | ||
}; | ||
Connector.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
@@ -514,6 +562,6 @@ if (nextProps.select !== this.props.select) { | ||
Connector.prototype.selectState = function selectState(props, context) { | ||
var state = context.redux.getState(); | ||
var state = context.store.getState(); | ||
var slice = props.select(state); | ||
(0, _invariant2['default'])((0, _utilsIsPlainObject2['default'])(slice), 'The return value of `select` prop must be an object. Instead received %s.', slice); | ||
_invariant2['default'](_utilsIsPlainObject2['default'](slice), 'The return value of `select` prop must be an object. Instead received %s.', slice); | ||
@@ -526,3 +574,3 @@ return { slice: slice }; | ||
var slice = this.state.slice; | ||
var dispatch = this.context.redux.dispatch; | ||
var dispatch = this.context.store.dispatch; | ||
@@ -535,3 +583,3 @@ return children(_extends({ dispatch: dispatch }, slice)); | ||
value: { | ||
redux: PropTypes.object.isRequired | ||
store: storeShape.isRequired | ||
}, | ||
@@ -561,3 +609,3 @@ enumerable: true | ||
/***/ }, | ||
/* 10 */ | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -586,3 +634,3 @@ | ||
return function provide(redux) { | ||
return function provide(store) { | ||
return function (DecoratedComponent) { | ||
@@ -593,5 +641,3 @@ return (function (_Component) { | ||
if (_Component != null) { | ||
_Component.apply(this, arguments); | ||
} | ||
_Component.apply(this, arguments); | ||
} | ||
@@ -606,3 +652,3 @@ | ||
Provider, | ||
{ redux: redux }, | ||
{ store: store }, | ||
function () { | ||
@@ -616,3 +662,3 @@ return React.createElement(DecoratedComponent, _this.props); | ||
key: 'displayName', | ||
value: 'Provider(' + (0, _utilsGetDisplayName2['default'])(DecoratedComponent) + ')', | ||
value: 'Provider(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')', | ||
enumerable: true | ||
@@ -634,17 +680,23 @@ }, { | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports) { | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = 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; }; })(); | ||
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; }; })(); | ||
exports["default"] = createProvider; | ||
exports['default'] = createProvider; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
var _utilsCreateStoreShape = __webpack_require__(3); | ||
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape); | ||
function createProvider(React) { | ||
@@ -654,7 +706,3 @@ var Component = React.Component; | ||
var reduxShape = PropTypes.shape({ | ||
subscribe: PropTypes.func.isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
getState: PropTypes.func.isRequired | ||
}); | ||
var storeShape = _utilsCreateStoreShape2['default'](PropTypes); | ||
@@ -666,3 +714,3 @@ return (function (_Component) { | ||
_Component.call(this, props, context); | ||
this.state = { redux: props.redux }; | ||
this.state = { store: props.store }; | ||
} | ||
@@ -673,12 +721,12 @@ | ||
Provider.prototype.getChildContext = function getChildContext() { | ||
return { redux: this.state.redux }; | ||
return { store: this.state.store }; | ||
}; | ||
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var redux = this.state.redux; | ||
var nextRedux = nextProps.redux; | ||
var store = this.state.store; | ||
var nextStore = nextProps.store; | ||
if (redux !== nextRedux) { | ||
var nextDispatcher = nextRedux.getDispatcher(); | ||
redux.replaceDispatcher(nextDispatcher); | ||
if (store !== nextStore) { | ||
var nextReducer = nextStore.getReducer(); | ||
store.replaceReducer(nextReducer); | ||
} | ||
@@ -694,12 +742,11 @@ }; | ||
_createClass(Provider, null, [{ | ||
key: "propTypes", | ||
key: 'childContextTypes', | ||
value: { | ||
redux: reduxShape.isRequired, | ||
children: PropTypes.func.isRequired | ||
store: storeShape.isRequired | ||
}, | ||
enumerable: true | ||
}, { | ||
key: "childContextTypes", | ||
key: 'propTypes', | ||
value: { | ||
redux: reduxShape.isRequired | ||
children: PropTypes.func.isRequired | ||
}, | ||
@@ -713,6 +760,6 @@ enumerable: true | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 12 */ | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -723,24 +770,53 @@ | ||
exports.__esModule = true; | ||
var _bind = Function.prototype.bind; | ||
exports['default'] = createRedux; | ||
exports['default'] = createStore; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _Redux = __webpack_require__(6); | ||
var _Store = __webpack_require__(8); | ||
var _Redux2 = _interopRequireDefault(_Redux); | ||
var _Store2 = _interopRequireDefault(_Store); | ||
function createRedux() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
var _utilsComposeReducers = __webpack_require__(2); | ||
var _utilsComposeReducers2 = _interopRequireDefault(_utilsComposeReducers); | ||
var _utilsComposeMiddleware = __webpack_require__(1); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var _middlewareThunk = __webpack_require__(16); | ||
var _middlewareThunk2 = _interopRequireDefault(_middlewareThunk); | ||
var defaultMiddlewares = function defaultMiddlewares(_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
return [_middlewareThunk2['default']({ dispatch: dispatch, getState: getState })]; | ||
}; | ||
function createStore(reducer, initialState) { | ||
var middlewares = arguments[2] === undefined ? defaultMiddlewares : arguments[2]; | ||
var finalReducer = typeof reducer === 'function' ? reducer : _utilsComposeReducers2['default'](reducer); | ||
var store = new _Store2['default'](finalReducer, initialState); | ||
var getState = store.getState.bind(store); | ||
var rawDispatch = store.dispatch.bind(store); | ||
var cookedDispatch = null; | ||
function dispatch(action) { | ||
return cookedDispatch(action); | ||
} | ||
var redux = new (_bind.apply(_Redux2['default'], [null].concat(args)))(); | ||
var finalMiddlewares = typeof middlewares === 'function' ? middlewares({ dispatch: dispatch, getState: getState }) : middlewares; | ||
cookedDispatch = _utilsComposeMiddleware2['default'].apply(undefined, finalMiddlewares.concat([rawDispatch])); | ||
return { | ||
subscribe: redux.subscribe.bind(redux), | ||
dispatch: redux.dispatch.bind(redux), | ||
getState: redux.getState.bind(redux), | ||
getDispatcher: redux.getDispatcher.bind(redux), | ||
replaceDispatcher: redux.replaceDispatcher.bind(redux) | ||
dispatch: cookedDispatch, | ||
subscribe: store.subscribe.bind(store), | ||
getState: store.getState.bind(store), | ||
getReducer: store.getReducer.bind(store), | ||
replaceReducer: store.replaceReducer.bind(store) | ||
}; | ||
@@ -752,3 +828,3 @@ } | ||
/***/ }, | ||
/* 13 */ | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -763,32 +839,27 @@ | ||
var _createRedux = __webpack_require__(12); | ||
var _createStore = __webpack_require__(14); | ||
var _createRedux2 = _interopRequireDefault(_createRedux); | ||
var _createStore2 = _interopRequireDefault(_createStore); | ||
var _createDispatcher = __webpack_require__(1); | ||
var _createDispatcher2 = _interopRequireDefault(_createDispatcher); | ||
// Utilities | ||
var _utilsComposeMiddleware = __webpack_require__(2); | ||
var _utilsComposeMiddleware = __webpack_require__(1); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var _utilsComposeStores = __webpack_require__(3); | ||
var _utilsComposeReducers = __webpack_require__(2); | ||
var _utilsComposeStores2 = _interopRequireDefault(_utilsComposeStores); | ||
var _utilsComposeReducers2 = _interopRequireDefault(_utilsComposeReducers); | ||
var _utilsBindActionCreators = __webpack_require__(16); | ||
var _utilsBindActionCreators = __webpack_require__(18); | ||
var _utilsBindActionCreators2 = _interopRequireDefault(_utilsBindActionCreators); | ||
exports.createRedux = _createRedux2['default']; | ||
exports.createDispatcher = _createDispatcher2['default']; | ||
exports.createStore = _createStore2['default']; | ||
exports.composeMiddleware = _utilsComposeMiddleware2['default']; | ||
exports.composeStores = _utilsComposeStores2['default']; | ||
exports.composeReducers = _utilsComposeReducers2['default']; | ||
exports.bindActionCreators = _utilsBindActionCreators2['default']; | ||
/***/ }, | ||
/* 14 */ | ||
/* 16 */ | ||
/***/ function(module, exports) { | ||
@@ -801,9 +872,10 @@ | ||
function thunkMiddleware(getState) { | ||
function thunkMiddleware(_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
return function (next) { | ||
var recurse = function recurse(action) { | ||
return typeof action === 'function' ? action(recurse, getState) : next(action); | ||
return function (action) { | ||
return typeof action === 'function' ? action(dispatch, getState) : next(action); | ||
}; | ||
return recurse; | ||
}; | ||
@@ -815,3 +887,3 @@ } | ||
/***/ }, | ||
/* 15 */ | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -829,7 +901,7 @@ | ||
var _componentsCreateAll = __webpack_require__(7); | ||
var _componentsCreateAll = __webpack_require__(9); | ||
var _componentsCreateAll2 = _interopRequireDefault(_componentsCreateAll); | ||
var _createAll = (0, _componentsCreateAll2['default'])(_react2['default']); | ||
var _createAll = _componentsCreateAll2['default'](_react2['default']); | ||
@@ -846,3 +918,3 @@ var Provider = _createAll.Provider; | ||
/***/ }, | ||
/* 16 */ | ||
/* 18 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -857,3 +929,3 @@ | ||
var _utilsMapValues = __webpack_require__(5); | ||
var _utilsMapValues = __webpack_require__(6); | ||
@@ -863,9 +935,5 @@ var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); | ||
function bindActionCreators(actionCreators, dispatch) { | ||
return (0, _utilsMapValues2['default'])(actionCreators, function (actionCreator) { | ||
return _utilsMapValues2['default'](actionCreators, function (actionCreator) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return dispatch(actionCreator.apply(undefined, args)); | ||
return dispatch(actionCreator.apply(undefined, arguments)); | ||
}; | ||
@@ -878,3 +946,3 @@ }); | ||
/***/ }, | ||
/* 17 */ | ||
/* 19 */ | ||
/***/ function(module, exports) { | ||
@@ -894,20 +962,5 @@ | ||
/***/ }, | ||
/* 18 */ | ||
/* 20 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = isPlainObject; | ||
function isPlainObject(obj) { | ||
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false; | ||
} | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 19 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
@@ -930,3 +983,3 @@ | ||
/***/ }, | ||
/* 20 */ | ||
/* 21 */ | ||
/***/ function(module, exports) { | ||
@@ -965,3 +1018,3 @@ | ||
/***/ }, | ||
/* 21 */ | ||
/* 22 */ | ||
/***/ function(module, exports) { | ||
@@ -1011,61 +1064,2 @@ | ||
/***/ }, | ||
/* 22 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule invariant | ||
*/ | ||
'use strict'; | ||
/** | ||
* Use invariant() to assert state which your program assumes to be true. | ||
* | ||
* Provide sprintf-style format (only %s is supported) and arguments | ||
* to provide information about what broke and what you were | ||
* expecting. | ||
* | ||
* The invariant message will be stripped in production, but the invariant | ||
* will remain to ensure logic does not differ in production. | ||
*/ | ||
var invariant = function(condition, format, a, b, c, d, e, f) { | ||
if ((undefined) !== 'production') { | ||
if (format === undefined) { | ||
throw new Error('invariant requires an error message argument'); | ||
} | ||
} | ||
if (!condition) { | ||
var error; | ||
if (format === undefined) { | ||
error = new Error( | ||
'Minified exception occurred; use the non-minified dev environment ' + | ||
'for the full error message and additional helpful warnings.' | ||
); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
error = new Error( | ||
'Invariant Violation: ' + | ||
format.replace(/%s/g, function() { return args[argIndex++]; }) | ||
); | ||
} | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
}; | ||
module.exports = invariant; | ||
/***/ }, | ||
/* 23 */ | ||
@@ -1072,0 +1066,0 @@ /***/ function(module, exports) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Redux=t(require("react")):e.Redux=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function u(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n<r.length;n++){var u=r[n],o=Object.getOwnPropertyDescriptor(t,u);o&&o.configurable&&void 0===e[u]&&Object.defineProperty(e,u,o)}return e}t.__esModule=!0;var o=r(13);u(t,n(o));var i=r(15);u(t,n(i))},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e){var t=void 0===arguments[1]?[]:arguments[1];return function(r,n){function u(t){return c=n(e(c,t)),t}function o(){return c}var c=n(e(r,a)),s="function"==typeof t?t(o):t;return i.default.apply(void 0,s.concat([u]))}}t.__esModule=!0,t.default=u;var o=r(2),i=n(o),a={type:"@@INIT"};e.exports=t.default},function(e,t){"use strict";function r(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return t.reduceRight(function(e,t){return t(e)})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e){var t=c.default(e,function(e){return"function"==typeof e});return function(e,r){return void 0===e&&(e={}),i.default(t,function(t,n){return t(e[n],r)})}}t.__esModule=!0,t.default=u;var o=r(5),i=n(o),a=r(19),c=n(a);e.exports=t.default},function(e,t){"use strict";function r(e){return e.displayName||e.name||"Component"}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){return Object.keys(e).reduce(function(r,n){return r[n]=t(e[n],n),r},{})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var o=r(1),i=n(o),a=r(3),c=n(a),s=r(14),f=n(s),l=function(){function e(t,r){u(this,e);var n=t;"object"==typeof t&&(n=i.default(c.default(t),function(e){return[f.default(e)]})),this.state=r,this.listeners=[],this.replaceDispatcher(n)}return e.prototype.getDispatcher=function(){return this.dispatcher},e.prototype.replaceDispatcher=function(e){this.dispatcher=e,this.dispatchFn=e(this.state,this.setState.bind(this))},e.prototype.dispatch=function(e){return this.dispatchFn(e)},e.prototype.getState=function(){return this.state},e.prototype.setState=function(e){return this.state=e,this.listeners.forEach(function(e){return e()}),e},e.prototype.subscribe=function(e){var t=this.listeners;return t.push(e),function(){var r=t.indexOf(e);t.splice(r,1)}},e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e){var t=i.default(e),r=f.default(e),n=c.default(e,t),u=p.default(e,r);return{Provider:t,Connector:r,provide:n,connect:u}}t.__esModule=!0,t.default=u;var o=r(11),i=n(o),a=r(10),c=n(a),s=r(9),f=n(s),l=r(8),p=n(l);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var r=e.Component;return function(n){return function(i){return function(r){function s(){u(this,s),null!=r&&r.apply(this,arguments)}return o(s,r),s.prototype.shouldComponentUpdate=function(e){return!p.default(this.props,e)},s.prototype.render=function(){var r=this;return e.createElement(t,{select:function(e){return n(e,r.props)}},function(t){return e.createElement(i,a({},t,r.props))})},c(s,null,[{key:"displayName",value:"Connector("+f.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),s}(r)}}}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var s=r(4),f=n(s),l=r(21),p=n(l);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,r=e.PropTypes;return function(e){function t(r,n){u(this,t),e.call(this,r,n),this.unsubscribe=n.redux.subscribe(this.handleChange.bind(this)),this.state=this.selectState(r,n)}return o(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!this.isSliceEqual(this.state.slice,t.slice)||!p.default(this.props,e)},t.prototype.isSliceEqual=function(e,t){var r=e===t;return r?!0:"object"!=typeof e||"object"!=typeof t?r:p.default(e,t)},t.prototype.componentWillReceiveProps=function(e){e.select!==this.props.select&&this.handleChange(e)},t.prototype.componentWillUnmount=function(){this.unsubscribe()},t.prototype.handleChange=function(){var e=void 0===arguments[0]?this.props:arguments[0],t=this.selectState(e,this.context);this.setState(t)},t.prototype.selectState=function(e,t){var r=t.redux.getState(),n=e.select(r);return v.default(h.default(n),"The return value of `select` prop must be an object. Instead received %s.",n),{slice:n}},t.prototype.render=function(){var e=this.props.children,t=this.state.slice,r=this.context.redux.dispatch;return e(a({dispatch:r},t))},c(t,null,[{key:"contextTypes",value:{redux:r.object.isRequired},enumerable:!0},{key:"propTypes",value:{children:r.func.isRequired,select:r.func.isRequired},enumerable:!0},{key:"defaultProps",value:{select:f.default},enumerable:!0}]),t}(t)}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var s=r(17),f=n(s),l=r(20),p=n(l),d=r(18),h=n(d),y=r(22),v=n(y);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var r=e.Component;return function(n){return function(i){return function(r){function c(){u(this,c),null!=r&&r.apply(this,arguments)}return o(c,r),c.prototype.render=function(){var r=this;return e.createElement(t,{redux:n},function(){return e.createElement(i,r.props)})},a(c,null,[{key:"displayName",value:"Provider("+s.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),c}(r)}}}t.__esModule=!0;var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=i;var c=r(4),s=n(c);e.exports=t.default},function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function u(e){var t=e.Component,u=e.PropTypes,i=u.shape({subscribe:u.func.isRequired,dispatch:u.func.isRequired,getState:u.func.isRequired});return function(e){function t(n,u){r(this,t),e.call(this,n,u),this.state={redux:n.redux}}return n(t,e),t.prototype.getChildContext=function(){return{redux:this.state.redux}},t.prototype.componentWillReceiveProps=function(e){var t=this.state.redux,r=e.redux;if(t!==r){var n=r.getDispatcher();t.replaceDispatcher(n)}},t.prototype.render=function(){var e=this.props.children;return e()},o(t,null,[{key:"propTypes",value:{redux:i.isRequired,children:u.func.isRequired},enumerable:!0},{key:"childContextTypes",value:{redux:i.isRequired},enumerable:!0}]),t}(t)}t.__esModule=!0;var o=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];var n=new(o.apply(a.default,[null].concat(t)));return{subscribe:n.subscribe.bind(n),dispatch:n.dispatch.bind(n),getState:n.getState.bind(n),getDispatcher:n.getDispatcher.bind(n),replaceDispatcher:n.replaceDispatcher.bind(n)}}t.__esModule=!0;var o=Function.prototype.bind;t.default=u;var i=r(6),a=n(i);e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var u=r(12),o=n(u),i=r(1),a=n(i),c=r(2),s=n(c),f=r(3),l=n(f),p=r(16),d=n(p);t.createRedux=o.default,t.createDispatcher=a.default,t.composeMiddleware=s.default,t.composeStores=l.default,t.bindActionCreators=d.default},function(e,t){"use strict";function r(e){return function(t){var r=function n(r){return"function"==typeof r?r(n,e):t(r)};return r}}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var u=r(23),o=n(u),i=r(7),a=n(i),c=a.default(o.default),s=c.Provider,f=c.Connector,l=c.provide,p=c.connect;t.Provider=s,t.Connector=f,t.provide=l,t.connect=p},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function u(e,t){return i.default(e,function(e){return function(){for(var r=arguments.length,n=Array(r),u=0;r>u;u++)n[u]=arguments[u];return t(e.apply(void 0,n))}})}t.__esModule=!0,t.default=u;var o=r(5),i=n(o);e.exports=t.default},function(e,t){"use strict";function r(e){return e}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e){return e?"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype:!1}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){return Object.keys(e).reduce(function(r,n){return t(e[n])&&(r[n]=e[n]),r},{})}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var u=Object.prototype.hasOwnProperty,o=0;o<r.length;o++)if(!u.call(t,r[o])||e[r[o]]!==t[r[o]])return!1;return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t){"use strict";function r(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var u=Object.prototype.hasOwnProperty,o=0;o<r.length;o++){if(!u.call(t,r[o]))return!1;var i=e[r[o]],a=t[r[o]];if(i!==a||"object"==typeof i||"object"==typeof a)return!1}return!0}t.__esModule=!0,t.default=r,e.exports=t.default},function(e,t,r){"use strict";var n=function(e,t,r,n,u,o,i,a){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[r,n,u,o,i,a],f=0;c=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return s[f++]}))}throw c.framesToPop=1,c}};e.exports=n},function(t,r){t.exports=e}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.Redux=t(require("react")):e.Redux=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function o(e,t){for(var n=Object.getOwnPropertyNames(t),r=0;r<n.length;r++){var o=n[r],u=Object.getOwnPropertyDescriptor(t,o);u&&u.configurable&&void 0===e[o]&&Object.defineProperty(e,o,u)}return e}t.__esModule=!0;var u=n(15);o(t,r(u));var i=n(17);o(t,r(i))},function(e,t){"use strict";function n(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return t.reduceRight(function(e,t){return t(e)})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=a.default(e,function(e){return"function"==typeof e});return function(e,n){return void 0===e&&(e={}),i.default(t,function(t,r){return t(e[r],n)})}}t.__esModule=!0,t.default=o;var u=n(6),i=r(u),c=n(20),a=r(c);e.exports=t.default},function(e,t){"use strict";function n(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e){return e?"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype:!1}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){return Object.keys(e).reduce(function(n,r){return n[r]=t(e[r],r),n},{})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";var r=function(e,t,n,r,o,u,i,c){if(!e){var a;if(void 0===t)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,o,u,i,c],f=0;a=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return s[f++]}))}throw a.framesToPop=1,a}};e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var u=n(7),i=r(u),c=n(5),a=r(c),s=function(){function e(t,n){o(this,e),i.default("function"==typeof t,"Expected the reducer to be a function."),this.state=n,this.listeners=[],this.replaceReducer(t)}return e.prototype.getReducer=function(){return this.reducer},e.prototype.replaceReducer=function(e){this.reducer=e,this.dispatch({type:"@@INIT"})},e.prototype.dispatch=function(e){i.default(a.default(e),"Actions must be plain objects. Use custom middleware for async actions.");var t=this.reducer;return this.state=t(this.state,e),this.listeners.forEach(function(e){return e()}),e},e.prototype.getState=function(){return this.state},e.prototype.subscribe=function(e){var t=this.listeners;return t.push(e),function(){var n=t.indexOf(e);t.splice(n,1)}},e}();t.default=s,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i.default(e),n=f.default(e),r=a.default(e,t),o=p.default(e,n);return{Provider:t,Connector:n,provide:r,connect:o}}t.__esModule=!0,t.default=o;var u=n(13),i=r(u),c=n(12),a=r(c),s=n(11),f=r(s),l=n(10),p=r(l);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function s(){o(this,s),n.apply(this,arguments)}return u(s,n),s.prototype.shouldComponentUpdate=function(e){return!p.default(this.props,e)},s.prototype.render=function(){var n=this;return e.createElement(t,{select:function(e){return r(e,n.props)}},function(t){return e.createElement(i,c({},t,n.props))})},a(s,null,[{key:"displayName",value:"Connector("+f.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),s}(n)}}}t.__esModule=!0;var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(4),f=r(s),l=n(22),p=r(l);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=f.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state=this.selectState(n,r)}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!this.isSliceEqual(this.state.slice,t.slice)||!y.default(this.props,e)},t.prototype.isSliceEqual=function(e,t){var n=e===t;return n?!0:"object"!=typeof e||"object"!=typeof t?n:y.default(e,t)},t.prototype.componentDidMount=function(){this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this))},t.prototype.componentWillReceiveProps=function(e){e.select!==this.props.select&&this.handleChange(e)},t.prototype.componentWillUnmount=function(){this.unsubscribe()},t.prototype.handleChange=function(){var e=void 0===arguments[0]?this.props:arguments[0],t=this.selectState(e,this.context);this.setState(t)},t.prototype.selectState=function(e,t){var n=t.store.getState(),r=e.select(n);return _.default(b.default(r),"The return value of `select` prop must be an object. Instead received %s.",r),{slice:r}},t.prototype.render=function(){var e=this.props.children,t=this.state.slice,n=this.context.store.dispatch;return e(c({dispatch:n},t))},a(t,null,[{key:"contextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired,select:n.func.isRequired},enumerable:!0},{key:"defaultProps",value:{select:p.default},enumerable:!0}]),t}(t)}t.__esModule=!0;var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(3),f=r(s),l=n(19),p=r(l),d=n(21),y=r(d),h=n(5),b=r(h),v=n(7),_=r(v);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function a(){o(this,a),n.apply(this,arguments)}return u(a,n),a.prototype.render=function(){var n=this;return e.createElement(t,{store:r},function(){return e.createElement(i,n.props)})},c(a,null,[{key:"displayName",value:"Provider("+s.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),a}(n)}}}t.__esModule=!0;var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var a=n(4),s=r(a);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=s.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state={store:n.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,n=e.store;if(t!==n){var r=n.getReducer();t.replaceReducer(r)}},t.prototype.render=function(){var e=this.props.children;return e()},c(t,null,[{key:"childContextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired},enumerable:!0}]),t}(t)}t.__esModule=!0;var c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var a=n(3),s=r(a);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){function n(e){return l(e)}var r=void 0===arguments[2]?d:arguments[2],o="function"==typeof e?e:a.default(e),u=new i.default(o,t),c=u.getState.bind(u),s=u.dispatch.bind(u),l=null,p="function"==typeof r?r({dispatch:n,getState:c}):r;return l=f.default.apply(void 0,p.concat([s])),{dispatch:l,subscribe:u.subscribe.bind(u),getState:u.getState.bind(u),getReducer:u.getReducer.bind(u),replaceReducer:u.replaceReducer.bind(u)}}t.__esModule=!0,t.default=o;var u=n(8),i=r(u),c=n(2),a=r(c),s=n(1),f=r(s),l=n(16),p=r(l),d=function(e){var t=e.dispatch,n=e.getState;return[p.default({dispatch:t,getState:n})]};e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(14),u=r(o),i=n(1),c=r(i),a=n(2),s=r(a),f=n(18),l=r(f);t.createStore=u.default,t.composeMiddleware=c.default,t.composeReducers=s.default,t.bindActionCreators=l.default},function(e,t){"use strict";function n(e){var t=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(t,n):e(r)}}}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(23),u=r(o),i=n(9),c=r(i),a=c.default(u.default),s=a.Provider,f=a.Connector,l=a.provide,p=a.connect;t.Provider=s,t.Connector=f,t.provide=l,t.connect=p},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return i.default(e,function(e){return function(){return t(e.apply(void 0,arguments))}})}t.__esModule=!0,t.default=o;var u=n(6),i=r(u);e.exports=t.default},function(e,t){"use strict";function n(e){return e}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){return Object.keys(e).reduce(function(n,r){return t(e[r])&&(n[r]=e[r]),n},{})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++)if(!o.call(t,n[u])||e[n[u]]!==t[n[u]])return!1;return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++){if(!o.call(t,n[u]))return!1;var i=e[n[u]],c=t[n[u]];if(i!==c||"object"==typeof i||"object"==typeof c)return!1}return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(t,n){t.exports=e}])}); |
@@ -65,3 +65,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _index = __webpack_require__(7); | ||
var _index = __webpack_require__(6); | ||
@@ -72,44 +72,2 @@ _defaults(exports, _interopRequireWildcard(_index)); | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = createDispatcher; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _utilsComposeMiddleware = __webpack_require__(2); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var INIT_ACTION = { | ||
type: '@@INIT' | ||
}; | ||
function createDispatcher(store) { | ||
var middlewares = arguments[1] === undefined ? [] : arguments[1]; | ||
return function dispatcher(initialState, setState) { | ||
var state = setState(store(initialState, INIT_ACTION)); | ||
function dispatch(action) { | ||
state = setState(store(state, action)); | ||
return action; | ||
} | ||
function getState() { | ||
return state; | ||
} | ||
var finalMiddlewares = typeof middlewares === 'function' ? middlewares(getState) : middlewares; | ||
return _utilsComposeMiddleware2['default'].apply(undefined, finalMiddlewares.concat([dispatch])); | ||
}; | ||
} | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
@@ -135,3 +93,3 @@ | ||
/***/ }, | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -142,7 +100,7 @@ | ||
exports.__esModule = true; | ||
exports['default'] = composeStores; | ||
exports['default'] = composeReducers; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _utilsMapValues = __webpack_require__(4); | ||
var _utilsMapValues = __webpack_require__(3); | ||
@@ -155,10 +113,11 @@ var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); | ||
function composeStores(stores) { | ||
var finalStores = (0, _utilsPick2['default'])(stores, function (val) { | ||
function composeReducers(reducers) { | ||
var finalReducers = _utilsPick2['default'](reducers, function (val) { | ||
return typeof val === 'function'; | ||
}); | ||
return function Composition(atom, action) { | ||
if (atom === undefined) atom = {}; | ||
return (0, _utilsMapValues2['default'])(finalStores, function (store, key) { | ||
return _utilsMapValues2['default'](finalReducers, function (store, key) { | ||
return store(atom[key], action); | ||
@@ -172,3 +131,3 @@ }); | ||
/***/ }, | ||
/* 4 */ | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
@@ -191,3 +150,3 @@ | ||
/***/ }, | ||
/* 5 */ | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -203,57 +162,47 @@ | ||
var _createDispatcher = __webpack_require__(1); | ||
var _invariant = __webpack_require__(11); | ||
var _createDispatcher2 = _interopRequireDefault(_createDispatcher); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _utilsComposeStores = __webpack_require__(3); | ||
var _utilsIsPlainObject = __webpack_require__(9); | ||
var _utilsComposeStores2 = _interopRequireDefault(_utilsComposeStores); | ||
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); | ||
var _middlewareThunk = __webpack_require__(8); | ||
var Store = (function () { | ||
function Store(reducer, initialState) { | ||
_classCallCheck(this, Store); | ||
var _middlewareThunk2 = _interopRequireDefault(_middlewareThunk); | ||
_invariant2['default'](typeof reducer === 'function', 'Expected the reducer to be a function.'); | ||
var Redux = (function () { | ||
function Redux(dispatcher, initialState) { | ||
_classCallCheck(this, Redux); | ||
var finalDispatcher = dispatcher; | ||
if (typeof dispatcher === 'object') { | ||
// A shortcut notation to use the default dispatcher | ||
finalDispatcher = (0, _createDispatcher2['default'])((0, _utilsComposeStores2['default'])(dispatcher), function (getState) { | ||
return [(0, _middlewareThunk2['default'])(getState)]; | ||
}); | ||
} | ||
this.state = initialState; | ||
this.listeners = []; | ||
this.replaceDispatcher(finalDispatcher); | ||
this.replaceReducer(reducer); | ||
} | ||
Redux.prototype.getDispatcher = function getDispatcher() { | ||
return this.dispatcher; | ||
Store.prototype.getReducer = function getReducer() { | ||
return this.reducer; | ||
}; | ||
Redux.prototype.replaceDispatcher = function replaceDispatcher(nextDispatcher) { | ||
this.dispatcher = nextDispatcher; | ||
this.dispatchFn = nextDispatcher(this.state, this.setState.bind(this)); | ||
Store.prototype.replaceReducer = function replaceReducer(nextReducer) { | ||
this.reducer = nextReducer; | ||
this.dispatch({ type: '@@INIT' }); | ||
}; | ||
Redux.prototype.dispatch = function dispatch(action) { | ||
return this.dispatchFn(action); | ||
}; | ||
Store.prototype.dispatch = function dispatch(action) { | ||
_invariant2['default'](_utilsIsPlainObject2['default'](action), 'Actions must be plain objects. Use custom middleware for async actions.'); | ||
Redux.prototype.getState = function getState() { | ||
return this.state; | ||
}; | ||
var reducer = this.reducer; | ||
Redux.prototype.setState = function setState(nextState) { | ||
this.state = nextState; | ||
this.state = reducer(this.state, action); | ||
this.listeners.forEach(function (listener) { | ||
return listener(); | ||
}); | ||
return nextState; | ||
return action; | ||
}; | ||
Redux.prototype.subscribe = function subscribe(listener) { | ||
Store.prototype.getState = function getState() { | ||
return this.state; | ||
}; | ||
Store.prototype.subscribe = function subscribe(listener) { | ||
var listeners = this.listeners; | ||
@@ -269,10 +218,10 @@ | ||
return Redux; | ||
return Store; | ||
})(); | ||
exports['default'] = Redux; | ||
exports['default'] = Store; | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 6 */ | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -283,24 +232,53 @@ | ||
exports.__esModule = true; | ||
var _bind = Function.prototype.bind; | ||
exports['default'] = createRedux; | ||
exports['default'] = createStore; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _Redux = __webpack_require__(5); | ||
var _Store = __webpack_require__(4); | ||
var _Redux2 = _interopRequireDefault(_Redux); | ||
var _Store2 = _interopRequireDefault(_Store); | ||
function createRedux() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
var _utilsComposeReducers = __webpack_require__(2); | ||
var _utilsComposeReducers2 = _interopRequireDefault(_utilsComposeReducers); | ||
var _utilsComposeMiddleware = __webpack_require__(1); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var _middlewareThunk = __webpack_require__(7); | ||
var _middlewareThunk2 = _interopRequireDefault(_middlewareThunk); | ||
var defaultMiddlewares = function defaultMiddlewares(_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
return [_middlewareThunk2['default']({ dispatch: dispatch, getState: getState })]; | ||
}; | ||
function createStore(reducer, initialState) { | ||
var middlewares = arguments[2] === undefined ? defaultMiddlewares : arguments[2]; | ||
var finalReducer = typeof reducer === 'function' ? reducer : _utilsComposeReducers2['default'](reducer); | ||
var store = new _Store2['default'](finalReducer, initialState); | ||
var getState = store.getState.bind(store); | ||
var rawDispatch = store.dispatch.bind(store); | ||
var cookedDispatch = null; | ||
function dispatch(action) { | ||
return cookedDispatch(action); | ||
} | ||
var redux = new (_bind.apply(_Redux2['default'], [null].concat(args)))(); | ||
var finalMiddlewares = typeof middlewares === 'function' ? middlewares({ dispatch: dispatch, getState: getState }) : middlewares; | ||
cookedDispatch = _utilsComposeMiddleware2['default'].apply(undefined, finalMiddlewares.concat([rawDispatch])); | ||
return { | ||
subscribe: redux.subscribe.bind(redux), | ||
dispatch: redux.dispatch.bind(redux), | ||
getState: redux.getState.bind(redux), | ||
getDispatcher: redux.getDispatcher.bind(redux), | ||
replaceDispatcher: redux.replaceDispatcher.bind(redux) | ||
dispatch: cookedDispatch, | ||
subscribe: store.subscribe.bind(store), | ||
getState: store.getState.bind(store), | ||
getReducer: store.getReducer.bind(store), | ||
replaceReducer: store.replaceReducer.bind(store) | ||
}; | ||
@@ -312,3 +290,3 @@ } | ||
/***/ }, | ||
/* 7 */ | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -323,32 +301,27 @@ | ||
var _createRedux = __webpack_require__(6); | ||
var _createStore = __webpack_require__(5); | ||
var _createRedux2 = _interopRequireDefault(_createRedux); | ||
var _createStore2 = _interopRequireDefault(_createStore); | ||
var _createDispatcher = __webpack_require__(1); | ||
var _createDispatcher2 = _interopRequireDefault(_createDispatcher); | ||
// Utilities | ||
var _utilsComposeMiddleware = __webpack_require__(2); | ||
var _utilsComposeMiddleware = __webpack_require__(1); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
var _utilsComposeStores = __webpack_require__(3); | ||
var _utilsComposeReducers = __webpack_require__(2); | ||
var _utilsComposeStores2 = _interopRequireDefault(_utilsComposeStores); | ||
var _utilsComposeReducers2 = _interopRequireDefault(_utilsComposeReducers); | ||
var _utilsBindActionCreators = __webpack_require__(9); | ||
var _utilsBindActionCreators = __webpack_require__(8); | ||
var _utilsBindActionCreators2 = _interopRequireDefault(_utilsBindActionCreators); | ||
exports.createRedux = _createRedux2['default']; | ||
exports.createDispatcher = _createDispatcher2['default']; | ||
exports.createStore = _createStore2['default']; | ||
exports.composeMiddleware = _utilsComposeMiddleware2['default']; | ||
exports.composeStores = _utilsComposeStores2['default']; | ||
exports.composeReducers = _utilsComposeReducers2['default']; | ||
exports.bindActionCreators = _utilsBindActionCreators2['default']; | ||
/***/ }, | ||
/* 8 */ | ||
/* 7 */ | ||
/***/ function(module, exports) { | ||
@@ -361,9 +334,10 @@ | ||
function thunkMiddleware(getState) { | ||
function thunkMiddleware(_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
return function (next) { | ||
var recurse = function recurse(action) { | ||
return typeof action === 'function' ? action(recurse, getState) : next(action); | ||
return function (action) { | ||
return typeof action === 'function' ? action(dispatch, getState) : next(action); | ||
}; | ||
return recurse; | ||
}; | ||
@@ -375,3 +349,3 @@ } | ||
/***/ }, | ||
/* 9 */ | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
@@ -386,3 +360,3 @@ | ||
var _utilsMapValues = __webpack_require__(4); | ||
var _utilsMapValues = __webpack_require__(3); | ||
@@ -392,9 +366,5 @@ var _utilsMapValues2 = _interopRequireDefault(_utilsMapValues); | ||
function bindActionCreators(actionCreators, dispatch) { | ||
return (0, _utilsMapValues2['default'])(actionCreators, function (actionCreator) { | ||
return _utilsMapValues2['default'](actionCreators, function (actionCreator) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return dispatch(actionCreator.apply(undefined, args)); | ||
return dispatch(actionCreator.apply(undefined, arguments)); | ||
}; | ||
@@ -407,2 +377,17 @@ }); | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
exports.__esModule = true; | ||
exports['default'] = isPlainObject; | ||
function isPlainObject(obj) { | ||
return obj ? typeof obj === 'object' && Object.getPrototypeOf(obj) === Object.prototype : false; | ||
} | ||
module.exports = exports['default']; | ||
/***/ }, | ||
/* 10 */ | ||
@@ -427,2 +412,61 @@ /***/ function(module, exports) { | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* Copyright 2013-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule invariant | ||
*/ | ||
'use strict'; | ||
/** | ||
* Use invariant() to assert state which your program assumes to be true. | ||
* | ||
* Provide sprintf-style format (only %s is supported) and arguments | ||
* to provide information about what broke and what you were | ||
* expecting. | ||
* | ||
* The invariant message will be stripped in production, but the invariant | ||
* will remain to ensure logic does not differ in production. | ||
*/ | ||
var invariant = function(condition, format, a, b, c, d, e, f) { | ||
if ((undefined) !== 'production') { | ||
if (format === undefined) { | ||
throw new Error('invariant requires an error message argument'); | ||
} | ||
} | ||
if (!condition) { | ||
var error; | ||
if (format === undefined) { | ||
error = new Error( | ||
'Minified exception occurred; use the non-minified dev environment ' + | ||
'for the full error message and additional helpful warnings.' | ||
); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
error = new Error( | ||
'Invariant Violation: ' + | ||
format.replace(/%s/g, function() { return args[argIndex++]; }) | ||
); | ||
} | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
}; | ||
module.exports = invariant; | ||
/***/ } | ||
@@ -429,0 +473,0 @@ /******/ ]) |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.Redux=e():t.Redux=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={exports:{},id:r,loaded:!1};return t[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t,e){for(var n=Object.getOwnPropertyNames(e),r=0;r<n.length;r++){var u=n[r],o=Object.getOwnPropertyDescriptor(e,u);o&&o.configurable&&void 0===t[u]&&Object.defineProperty(t,u,o)}return t}e.__esModule=!0;var o=n(7);u(e,r(o))},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=void 0===arguments[1]?[]:arguments[1];return function(n,r){function u(e){return a=r(t(a,e)),e}function o(){return a}var a=r(t(n,s)),c="function"==typeof e?e(o):e;return i.default.apply(void 0,c.concat([u]))}}e.__esModule=!0,e.default=u;var o=n(2),i=r(o),s={type:"@@INIT"};t.exports=e.default},function(t,e){"use strict";function n(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return e.reduceRight(function(t,e){return e(t)})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=a.default(t,function(t){return"function"==typeof t});return function(t,n){return void 0===t&&(t={}),i.default(e,function(e,r){return e(t[r],n)})}}e.__esModule=!0,e.default=u;var o=n(4),i=r(o),s=n(10),a=r(s);t.exports=e.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return n[r]=e(t[r],r),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var o=n(1),i=r(o),s=n(3),a=r(s),c=n(8),f=r(c),d=function(){function t(e,n){u(this,t);var r=e;"object"==typeof e&&(r=i.default(a.default(e),function(t){return[f.default(t)]})),this.state=n,this.listeners=[],this.replaceDispatcher(r)}return t.prototype.getDispatcher=function(){return this.dispatcher},t.prototype.replaceDispatcher=function(t){this.dispatcher=t,this.dispatchFn=t(this.state,this.setState.bind(this))},t.prototype.dispatch=function(t){return this.dispatchFn(t)},t.prototype.getState=function(){return this.state},t.prototype.setState=function(t){return this.state=t,this.listeners.forEach(function(t){return t()}),t},t.prototype.subscribe=function(t){var e=this.listeners;return e.push(t),function(){var n=e.indexOf(t);e.splice(n,1)}},t}();e.default=d,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];var r=new(o.apply(s.default,[null].concat(e)));return{subscribe:r.subscribe.bind(r),dispatch:r.dispatch.bind(r),getState:r.getState.bind(r),getDispatcher:r.getDispatcher.bind(r),replaceDispatcher:r.replaceDispatcher.bind(r)}}e.__esModule=!0;var o=Function.prototype.bind;e.default=u;var i=n(5),s=r(i);t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var u=n(6),o=r(u),i=n(1),s=r(i),a=n(2),c=r(a),f=n(3),d=r(f),l=n(9),p=r(l);e.createRedux=o.default,e.createDispatcher=s.default,e.composeMiddleware=c.default,e.composeStores=d.default,e.bindActionCreators=p.default},function(t,e){"use strict";function n(t){return function(e){var n=function r(n){return"function"==typeof n?n(r,t):e(n)};return n}}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){return i.default(t,function(t){return function(){for(var n=arguments.length,r=Array(n),u=0;n>u;u++)r[u]=arguments[u];return e(t.apply(void 0,r))}})}e.__esModule=!0,e.default=u;var o=n(4),i=r(o);t.exports=e.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return e(t[r])&&(n[r]=t[r]),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):"object"==typeof exports?exports.Redux=e():t.Redux=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={exports:{},id:r,loaded:!1};return t[r].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function u(t,e){for(var n=Object.getOwnPropertyNames(e),r=0;r<n.length;r++){var u=n[r],o=Object.getOwnPropertyDescriptor(e,u);o&&o.configurable&&void 0===t[u]&&Object.defineProperty(t,u,o)}return t}e.__esModule=!0;var o=n(6);u(e,r(o))},function(t,e){"use strict";function n(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return e.reduceRight(function(t,e){return e(t)})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t){var e=f.default(t,function(t){return"function"==typeof t});return function(t,n){return void 0===t&&(t={}),i.default(e,function(e,r){return e(t[r],n)})}}e.__esModule=!0,e.default=u;var o=n(3),i=r(o),c=n(10),f=r(c);t.exports=e.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return n[r]=e(t[r],r),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}e.__esModule=!0;var o=n(11),i=r(o),c=n(9),f=r(c),s=function(){function t(e,n){u(this,t),i.default("function"==typeof e,"Expected the reducer to be a function."),this.state=n,this.listeners=[],this.replaceReducer(e)}return t.prototype.getReducer=function(){return this.reducer},t.prototype.replaceReducer=function(t){this.reducer=t,this.dispatch({type:"@@INIT"})},t.prototype.dispatch=function(t){i.default(f.default(t),"Actions must be plain objects. Use custom middleware for async actions.");var e=this.reducer;return this.state=e(this.state,t),this.listeners.forEach(function(t){return t()}),t},t.prototype.getState=function(){return this.state},t.prototype.subscribe=function(t){var e=this.listeners;return e.push(t),function(){var n=e.indexOf(t);e.splice(n,1)}},t}();e.default=s,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){function n(t){return d(t)}var r=void 0===arguments[2]?p:arguments[2],u="function"==typeof t?t:f.default(t),o=new i.default(u,e),c=o.getState.bind(o),s=o.dispatch.bind(o),d=null,l="function"==typeof r?r({dispatch:n,getState:c}):r;return d=a.default.apply(void 0,l.concat([s])),{dispatch:d,subscribe:o.subscribe.bind(o),getState:o.getState.bind(o),getReducer:o.getReducer.bind(o),replaceReducer:o.replaceReducer.bind(o)}}e.__esModule=!0,e.default=u;var o=n(4),i=r(o),c=n(2),f=r(c),s=n(1),a=r(s),d=n(7),l=r(d),p=function(t){var e=t.dispatch,n=t.getState;return[l.default({dispatch:e,getState:n})]};t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var u=n(5),o=r(u),i=n(1),c=r(i),f=n(2),s=r(f),a=n(8),d=r(a);e.createStore=o.default,e.composeMiddleware=c.default,e.composeReducers=s.default,e.bindActionCreators=d.default},function(t,e){"use strict";function n(t){var e=t.dispatch,n=t.getState;return function(t){return function(r){return"function"==typeof r?r(e,n):t(r)}}}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){return i.default(t,function(t){return function(){return e(t.apply(void 0,arguments))}})}e.__esModule=!0,e.default=u;var o=n(3),i=r(o);t.exports=e.default},function(t,e){"use strict";function n(t){return t?"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype:!1}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e){"use strict";function n(t,e){return Object.keys(t).reduce(function(n,r){return e(t[r])&&(n[r]=t[r]),n},{})}e.__esModule=!0,e.default=n,t.exports=e.default},function(t,e,n){"use strict";var r=function(t,e,n,r,u,o,i,c){if(!t){var f;if(void 0===e)f=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,u,o,i,c],a=0;f=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return s[a++]}))}throw f.framesToPop=1,f}};t.exports=r}])}); |
@@ -26,8 +26,8 @@ 'use strict'; | ||
// Wrapper components | ||
var Provider = (0, _createProvider2['default'])(React); | ||
var Connector = (0, _createConnector2['default'])(React); | ||
var Provider = _createProvider2['default'](React); | ||
var Connector = _createConnector2['default'](React); | ||
// Higher-order components (decorators) | ||
var provide = (0, _createProvideDecorator2['default'])(React, Provider); | ||
var connect = (0, _createConnectDecorator2['default'])(React, Connector); | ||
var provide = _createProvideDecorator2['default'](React, Provider); | ||
var connect = _createConnectDecorator2['default'](React, Connector); | ||
@@ -34,0 +34,0 @@ return { Provider: Provider, Connector: Connector, provide: provide, connect: connect }; |
@@ -34,5 +34,3 @@ 'use strict'; | ||
if (_Component != null) { | ||
_Component.apply(this, arguments); | ||
} | ||
_Component.apply(this, arguments); | ||
} | ||
@@ -43,3 +41,3 @@ | ||
ConnectorDecorator.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) { | ||
return !(0, _utilsShallowEqualScalar2['default'])(this.props, nextProps); | ||
return !_utilsShallowEqualScalar2['default'](this.props, nextProps); | ||
}; | ||
@@ -63,3 +61,3 @@ | ||
key: 'displayName', | ||
value: 'Connector(' + (0, _utilsGetDisplayName2['default'])(DecoratedComponent) + ')', | ||
value: 'Connector(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')', | ||
enumerable: true | ||
@@ -66,0 +64,0 @@ }, { |
@@ -17,2 +17,6 @@ 'use strict'; | ||
var _utilsCreateStoreShape = require('../utils/createStoreShape'); | ||
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape); | ||
var _utilsIdentity = require('../utils/identity'); | ||
@@ -38,2 +42,4 @@ | ||
var storeShape = _utilsCreateStoreShape2['default'](PropTypes); | ||
return (function (_Component) { | ||
@@ -44,4 +50,2 @@ function Connector(props, context) { | ||
_Component.call(this, props, context); | ||
this.unsubscribe = context.redux.subscribe(this.handleChange.bind(this)); | ||
this.state = this.selectState(props, context); | ||
@@ -53,3 +57,3 @@ } | ||
Connector.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) { | ||
return !this.isSliceEqual(this.state.slice, nextState.slice) || !(0, _utilsShallowEqual2['default'])(this.props, nextProps); | ||
return !this.isSliceEqual(this.state.slice, nextState.slice) || !_utilsShallowEqual2['default'](this.props, nextProps); | ||
}; | ||
@@ -64,5 +68,9 @@ | ||
} | ||
return (0, _utilsShallowEqual2['default'])(slice, nextSlice); | ||
return _utilsShallowEqual2['default'](slice, nextSlice); | ||
}; | ||
Connector.prototype.componentDidMount = function componentDidMount() { | ||
this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this)); | ||
}; | ||
Connector.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
@@ -87,6 +95,6 @@ if (nextProps.select !== this.props.select) { | ||
Connector.prototype.selectState = function selectState(props, context) { | ||
var state = context.redux.getState(); | ||
var state = context.store.getState(); | ||
var slice = props.select(state); | ||
(0, _invariant2['default'])((0, _utilsIsPlainObject2['default'])(slice), 'The return value of `select` prop must be an object. Instead received %s.', slice); | ||
_invariant2['default'](_utilsIsPlainObject2['default'](slice), 'The return value of `select` prop must be an object. Instead received %s.', slice); | ||
@@ -99,3 +107,3 @@ return { slice: slice }; | ||
var slice = this.state.slice; | ||
var dispatch = this.context.redux.dispatch; | ||
var dispatch = this.context.store.dispatch; | ||
@@ -108,3 +116,3 @@ return children(_extends({ dispatch: dispatch }, slice)); | ||
value: { | ||
redux: PropTypes.object.isRequired | ||
store: storeShape.isRequired | ||
}, | ||
@@ -111,0 +119,0 @@ enumerable: true |
@@ -22,3 +22,3 @@ 'use strict'; | ||
return function provide(redux) { | ||
return function provide(store) { | ||
return function (DecoratedComponent) { | ||
@@ -29,5 +29,3 @@ return (function (_Component) { | ||
if (_Component != null) { | ||
_Component.apply(this, arguments); | ||
} | ||
_Component.apply(this, arguments); | ||
} | ||
@@ -42,3 +40,3 @@ | ||
Provider, | ||
{ redux: redux }, | ||
{ store: store }, | ||
function () { | ||
@@ -52,3 +50,3 @@ return React.createElement(DecoratedComponent, _this.props); | ||
key: 'displayName', | ||
value: 'Provider(' + (0, _utilsGetDisplayName2['default'])(DecoratedComponent) + ')', | ||
value: 'Provider(' + _utilsGetDisplayName2['default'](DecoratedComponent) + ')', | ||
enumerable: true | ||
@@ -55,0 +53,0 @@ }, { |
@@ -1,13 +0,19 @@ | ||
"use strict"; | ||
'use strict'; | ||
exports.__esModule = 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; }; })(); | ||
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; }; })(); | ||
exports["default"] = createProvider; | ||
exports['default'] = createProvider; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } | ||
var _utilsCreateStoreShape = require('../utils/createStoreShape'); | ||
var _utilsCreateStoreShape2 = _interopRequireDefault(_utilsCreateStoreShape); | ||
function createProvider(React) { | ||
@@ -17,7 +23,3 @@ var Component = React.Component; | ||
var reduxShape = PropTypes.shape({ | ||
subscribe: PropTypes.func.isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
getState: PropTypes.func.isRequired | ||
}); | ||
var storeShape = _utilsCreateStoreShape2['default'](PropTypes); | ||
@@ -29,3 +31,3 @@ return (function (_Component) { | ||
_Component.call(this, props, context); | ||
this.state = { redux: props.redux }; | ||
this.state = { store: props.store }; | ||
} | ||
@@ -36,12 +38,12 @@ | ||
Provider.prototype.getChildContext = function getChildContext() { | ||
return { redux: this.state.redux }; | ||
return { store: this.state.store }; | ||
}; | ||
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var redux = this.state.redux; | ||
var nextRedux = nextProps.redux; | ||
var store = this.state.store; | ||
var nextStore = nextProps.store; | ||
if (redux !== nextRedux) { | ||
var nextDispatcher = nextRedux.getDispatcher(); | ||
redux.replaceDispatcher(nextDispatcher); | ||
if (store !== nextStore) { | ||
var nextReducer = nextStore.getReducer(); | ||
store.replaceReducer(nextReducer); | ||
} | ||
@@ -57,12 +59,11 @@ }; | ||
_createClass(Provider, null, [{ | ||
key: "propTypes", | ||
key: 'childContextTypes', | ||
value: { | ||
redux: reduxShape.isRequired, | ||
children: PropTypes.func.isRequired | ||
store: storeShape.isRequired | ||
}, | ||
enumerable: true | ||
}, { | ||
key: "childContextTypes", | ||
key: 'propTypes', | ||
value: { | ||
redux: reduxShape.isRequired | ||
children: PropTypes.func.isRequired | ||
}, | ||
@@ -76,2 +77,2 @@ enumerable: true | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -8,10 +8,6 @@ // Core | ||
var _createRedux = require('./createRedux'); | ||
var _createStore = require('./createStore'); | ||
var _createRedux2 = _interopRequireDefault(_createRedux); | ||
var _createStore2 = _interopRequireDefault(_createStore); | ||
var _createDispatcher = require('./createDispatcher'); | ||
var _createDispatcher2 = _interopRequireDefault(_createDispatcher); | ||
// Utilities | ||
@@ -23,5 +19,5 @@ | ||
var _utilsComposeStores = require('./utils/composeStores'); | ||
var _utilsComposeReducers = require('./utils/composeReducers'); | ||
var _utilsComposeStores2 = _interopRequireDefault(_utilsComposeStores); | ||
var _utilsComposeReducers2 = _interopRequireDefault(_utilsComposeReducers); | ||
@@ -32,6 +28,5 @@ var _utilsBindActionCreators = require('./utils/bindActionCreators'); | ||
exports.createRedux = _createRedux2['default']; | ||
exports.createDispatcher = _createDispatcher2['default']; | ||
exports.createStore = _createStore2['default']; | ||
exports.composeMiddleware = _utilsComposeMiddleware2['default']; | ||
exports.composeStores = _utilsComposeStores2['default']; | ||
exports.composeReducers = _utilsComposeReducers2['default']; | ||
exports.bindActionCreators = _utilsBindActionCreators2['default']; |
@@ -6,9 +6,10 @@ 'use strict'; | ||
function thunkMiddleware(getState) { | ||
function thunkMiddleware(_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
return function (next) { | ||
var recurse = function recurse(action) { | ||
return typeof action === 'function' ? action(recurse, getState) : next(action); | ||
return function (action) { | ||
return typeof action === 'function' ? action(dispatch, getState) : next(action); | ||
}; | ||
return recurse; | ||
}; | ||
@@ -15,0 +16,0 @@ } |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var _createAll = (0, _componentsCreateAll2['default'])(_reactNative2['default']); | ||
var _createAll = _componentsCreateAll2['default'](_reactNative2['default']); | ||
@@ -18,0 +18,0 @@ var Provider = _createAll.Provider; |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var _createAll = (0, _componentsCreateAll2['default'])(_react2['default']); | ||
var _createAll = _componentsCreateAll2['default'](_react2['default']); | ||
@@ -18,0 +18,0 @@ var Provider = _createAll.Provider; |
@@ -13,9 +13,5 @@ 'use strict'; | ||
function bindActionCreators(actionCreators, dispatch) { | ||
return (0, _utilsMapValues2['default'])(actionCreators, function (actionCreator) { | ||
return _utilsMapValues2['default'](actionCreators, function (actionCreator) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return dispatch(actionCreator.apply(undefined, args)); | ||
return dispatch(actionCreator.apply(undefined, arguments)); | ||
}; | ||
@@ -22,0 +18,0 @@ }); |
{ | ||
"name": "redux", | ||
"version": "0.12.0", | ||
"version": "1.0.0-alpha", | ||
"description": "Atomic Flux with hot reloading", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
redux | ||
========================= | ||
[![build status](https://img.shields.io/travis/gaearon/redux.svg?style=flat-square)](https://travis-ci.org/gaearon/redux) | ||
[![build status](https://img.shields.io/travis/gaearon/redux/master.svg?style=flat-square)](https://travis-ci.org/gaearon/redux) | ||
[![npm version](https://img.shields.io/npm/v/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux) | ||
[![redux channel on slack](https://img.shields.io/badge/slack-redux@reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com) | ||
Atomic Flux with hot reloading. | ||
Atomic Flux with hot reloading. | ||
**The API is likely to change a few times before we reach 1.0.** | ||
**The API is likely to change a few times before we reach 1.0.**<br> | ||
**Its [surface area](http://www.youtube.com/watch?v=4anAwXYqLG8) is minimal so you can try it in production and report any issues.** | ||
@@ -17,3 +18,5 @@ | ||
- [Demo](#demo) | ||
- [Running TodoMVC](#running-todomvc) | ||
- [Examples](#examples) | ||
- [Simple Examples](#simple-examples) | ||
- [Async and Universal Examples with Routing](#async-and-universal-examples-with-routing) | ||
- [What does it look like?](#what-does-it-look-like) | ||
@@ -31,3 +34,2 @@ - [Actions](#actions) | ||
- [FAQ](#faq) | ||
- [Any examples with data fetching and `react-router`?](#any-examples-with-data-fetching-and-react-router) | ||
- [How does hot reloading work?](#how-does-hot-reloading-work) | ||
@@ -53,3 +55,3 @@ - [Can I use this in production?](#can-i-use-this-in-production) | ||
* Prevents some of the anti-patterns common in Flux code. | ||
* Works great in isomoprhic apps because it doesn't use singletons and the data can be rehydrated. | ||
* Works great in [universal (aka “isomorphic”)](https://medium.com/@mjackson/universal-javascript-4761051b7ae9) apps because it doesn't use singletons and the data can be rehydrated. | ||
* Doesn't care how you store your data: you may use JS objects, arrays, ImmutableJS, etc. | ||
@@ -70,11 +72,27 @@ * Under the hood, it keeps all your data in a tree, but you don't need to think about it. | ||
## Running TodoMVC | ||
## Examples | ||
### Simple Examples | ||
Redux is distributed with a Counter and a TodoMVC example in its source code. | ||
First, clone the repo: | ||
``` | ||
git clone https://github.com/gaearon/redux.git redux | ||
git clone https://github.com/gaearon/redux.git | ||
cd redux | ||
``` | ||
cd redux | ||
Run the Counter example: | ||
``` | ||
cd redux/examples/counter | ||
npm install | ||
npm start | ||
``` | ||
cd examples/todomvc | ||
Run the TodoMVC example: | ||
``` | ||
cd ../todomvc | ||
npm install | ||
@@ -84,2 +102,13 @@ npm start | ||
### Async and Universal Examples with Routing | ||
These async and [universal (aka “isomorphic”)](https://medium.com/@mjackson/universal-javascript-4761051b7ae9) examples using React Router should help you get started: | ||
* [redux-react-router-async-example](https://github.com/emmenko/redux-react-router-async-example): Work in progress. Semi-official. Only the client side. Uses React Router. | ||
* [react-redux-universal-hot-example](https://github.com/erikras/react-redux-universal-hot-example): Universal. Uses React Router. | ||
* [redux-example](https://github.com/quangbuule/redux-example): Universal. Uses Immutable, React Router. | ||
* [isomorphic-counter-example](https://github.com/khtdr/redux-react-koa-isomorphic-counter-example): Universal. A bare-bone implentation of the [counter example app](https://github.com/gaearon/redux/tree/master/examples/counter). Uses promises-middleware to interact with API via Koa on the server. | ||
Don’t be shy, add your own! | ||
## What does it look like? | ||
@@ -345,6 +374,2 @@ | ||
### Any examples with data fetching and `react-router`? | ||
Besides the examples in this repo, there is an [officially supported example](https://github.com/emmenko/redux-react-router-async-example) (_still WIP_) tackling those implementations. | ||
### How does hot reloading work? | ||
@@ -351,0 +376,0 @@ |
import expect from 'expect'; | ||
import jsdomReact from './jsdomReact'; | ||
import React, { PropTypes, Component } from 'react/addons'; | ||
import { createRedux } from '../../src'; | ||
import { createStore } from '../../src'; | ||
import { connect, Connector } from '../../src/react'; | ||
@@ -16,7 +16,7 @@ | ||
static childContextTypes = { | ||
redux: PropTypes.object.isRequired | ||
store: PropTypes.object.isRequired | ||
} | ||
getChildContext() { | ||
return { redux: this.props.redux }; | ||
return { store: this.props.store }; | ||
} | ||
@@ -29,4 +29,6 @@ | ||
it('wraps component with Provider', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
it('should wrap the component into Provider', () => { | ||
const store = createStore(() => ({ | ||
foo: 'bar' | ||
})); | ||
@@ -41,4 +43,4 @@ @connect(state => state) | ||
const container = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
{() => <Container pass="through" />} | ||
<Provider store={store}> | ||
{() => <Container pass='through' />} | ||
</Provider> | ||
@@ -48,8 +50,40 @@ ); | ||
expect(div.props.pass).toEqual('through'); | ||
expect(div.props.test).toEqual('test'); | ||
expect(() => TestUtils.findRenderedComponentWithType(container, Connector)) | ||
.toNotThrow(); | ||
expect(div.props.foo).toEqual('bar'); | ||
expect(() => | ||
TestUtils.findRenderedComponentWithType(container, Connector) | ||
).toNotThrow(); | ||
}); | ||
it('sets displayName correctly', () => { | ||
it('should pass the only argument as the select prop down', () => { | ||
const store = createStore(() => ({ | ||
foo: 'baz', | ||
bar: 'baz' | ||
})); | ||
function select({ foo }) { | ||
return { foo }; | ||
} | ||
@connect(select) | ||
class Container extends Component { | ||
render() { | ||
return <div {...this.props} />; | ||
} | ||
} | ||
const container = TestUtils.renderIntoDocument( | ||
<Provider store={store}> | ||
{() => <Container pass='through' />} | ||
</Provider> | ||
); | ||
const connector = TestUtils.findRenderedComponentWithType(container, Connector); | ||
expect(connector.props.select({ | ||
foo: 5, | ||
bar: 7 | ||
})).toEqual({ | ||
foo: 5 | ||
}); | ||
}); | ||
it('should set the displayName correctly', () => { | ||
@connect(state => state) | ||
@@ -65,3 +99,3 @@ class Container extends Component { | ||
it('sets DecoratedComponent to wrapped component', () => { | ||
it('should expose the wrapped component as DecoratedComponent', () => { | ||
class Container extends Component { | ||
@@ -73,8 +107,8 @@ render() { | ||
let decorator = connect(state => state); | ||
let ConnectorDecorator = decorator(Container); | ||
const decorator = connect(state => state); | ||
const decorated = decorator(Container); | ||
expect(ConnectorDecorator.DecoratedComponent).toBe(Container); | ||
expect(decorated.DecoratedComponent).toBe(Container); | ||
}); | ||
}); | ||
}); |
import expect from 'expect'; | ||
import jsdomReact from './jsdomReact'; | ||
import React, { PropTypes, Component } from 'react/addons'; | ||
import { createRedux } from '../../src'; | ||
import { createStore } from '../../src'; | ||
import { Connector } from '../../src/react'; | ||
@@ -16,7 +16,7 @@ | ||
static childContextTypes = { | ||
redux: PropTypes.object.isRequired | ||
store: PropTypes.object.isRequired | ||
} | ||
getChildContext() { | ||
return { redux: this.props.redux }; | ||
return { store: this.props.store }; | ||
} | ||
@@ -29,13 +29,13 @@ | ||
const stringBuilder = (prev = '', action) => { | ||
function stringBuilder(prev = '', action) { | ||
return action.type === 'APPEND' | ||
? prev + action.body | ||
: prev; | ||
}; | ||
} | ||
it('gets Redux from context', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
it('should receive the store in the context', () => { | ||
const store = createStore({}); | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
@@ -50,12 +50,12 @@ <Connector> | ||
const connector = TestUtils.findRenderedComponentWithType(tree, Connector); | ||
expect(connector.context.redux).toBe(redux); | ||
expect(connector.context.store).toBe(store); | ||
}); | ||
it('subscribes to Redux changes', () => { | ||
const redux = createRedux({ string: stringBuilder }); | ||
it('should subscribe to the store changes', () => { | ||
const store = createStore(stringBuilder); | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={state => ({ string: state.string })}> | ||
<Connector select={string => ({ string })}> | ||
{({ string }) => <div string={string} />} | ||
@@ -69,15 +69,15 @@ </Connector> | ||
expect(div.props.string).toBe(''); | ||
redux.dispatch({ type: 'APPEND', body: 'a'}); | ||
store.dispatch({ type: 'APPEND', body: 'a'}); | ||
expect(div.props.string).toBe('a'); | ||
redux.dispatch({ type: 'APPEND', body: 'b'}); | ||
store.dispatch({ type: 'APPEND', body: 'b'}); | ||
expect(div.props.string).toBe('ab'); | ||
}); | ||
it('unsubscribes before unmounting', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
const subscribe = redux.subscribe; | ||
it('should unsubscribe before unmounting', () => { | ||
const store = createStore(stringBuilder); | ||
const subscribe = store.subscribe; | ||
// Keep track of unsubscribe by wrapping `subscribe()` | ||
// Keep track of unsubscribe by wrapping subscribe() | ||
const spy = expect.createSpy(() => {}); | ||
redux.subscribe = (listener) => { | ||
store.subscribe = (listener) => { | ||
const unsubscribe = subscribe(listener); | ||
@@ -91,5 +91,5 @@ return () => { | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={state => ({ string: state.string })}> | ||
<Connector select={string => ({ string })}> | ||
{({ string }) => <div string={string} />} | ||
@@ -107,4 +107,4 @@ </Connector> | ||
it('shallow compares selected state to prevent unnecessary updates', () => { | ||
const redux = createRedux({ string: stringBuilder }); | ||
it('should shallowly compare the selected state to prevent unnecessary updates', () => { | ||
const store = createStore(stringBuilder); | ||
const spy = expect.createSpy(() => {}); | ||
@@ -117,5 +117,5 @@ function render({ string }) { | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={state => ({ string: state.string })}> | ||
<Connector select={string => ({ string })}> | ||
{render} | ||
@@ -130,12 +130,15 @@ </Connector> | ||
expect(div.props.string).toBe(''); | ||
redux.dispatch({ type: 'APPEND', body: 'a'}); | ||
store.dispatch({ type: 'APPEND', body: 'a'}); | ||
expect(spy.calls.length).toBe(2); | ||
redux.dispatch({ type: 'APPEND', body: 'b'}); | ||
store.dispatch({ type: 'APPEND', body: 'b'}); | ||
expect(spy.calls.length).toBe(3); | ||
redux.dispatch({ type: 'APPEND', body: ''}); | ||
store.dispatch({ type: 'APPEND', body: ''}); | ||
expect(spy.calls.length).toBe(3); | ||
}); | ||
it('recomputes the state slice when `select` prop changes', () => { | ||
const redux = createRedux({ a: () => 42, b: () => 72 }); | ||
it('should recompute the state slice when the select prop changes', () => { | ||
const store = createStore({ | ||
a: () => 42, | ||
b: () => 72 | ||
}); | ||
@@ -162,3 +165,3 @@ function selectA(state) { | ||
return ( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => | ||
@@ -182,7 +185,7 @@ <Connector select={this.state.select}> | ||
it('passes `dispatch()` to child function', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
it('should pass dispatch() to the child function', () => { | ||
const store = createStore({}); | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
@@ -197,13 +200,13 @@ <Connector> | ||
const div = TestUtils.findRenderedDOMComponentWithTag(tree, 'div'); | ||
expect(div.props.dispatch).toBe(redux.dispatch); | ||
expect(div.props.dispatch).toBe(store.dispatch); | ||
}); | ||
it('should throw an error if `state` returns anything but a plain object', () => { | ||
const redux = createRedux(() => {}); | ||
it('should throw an error if select returns anything but a plain object', () => { | ||
const store = createStore({}); | ||
expect(() => { | ||
TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector state={() => 1}> | ||
<Connector select={() => 1}> | ||
{() => <div />} | ||
@@ -215,4 +218,60 @@ </Connector> | ||
}).toThrow(/select/); | ||
expect(() => { | ||
TestUtils.renderIntoDocument( | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={() => 'hey'}> | ||
{() => <div />} | ||
</Connector> | ||
)} | ||
</Provider> | ||
); | ||
}).toThrow(/select/); | ||
function AwesomeMap() { } | ||
expect(() => { | ||
TestUtils.renderIntoDocument( | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={() => new AwesomeMap()}> | ||
{() => <div />} | ||
</Connector> | ||
)} | ||
</Provider> | ||
); | ||
}).toThrow(/select/); | ||
}); | ||
it('should not setState when renderToString is called on the server', () => { | ||
const { renderToString } = React; | ||
const store = createStore(stringBuilder); | ||
class TestComp extends Component { | ||
componentWillMount() { | ||
store.dispatch({ | ||
type: 'APPEND', | ||
body: 'a' | ||
}); | ||
} | ||
render() { | ||
return (<div>{this.props.string}</div>); | ||
} | ||
} | ||
const el = ( | ||
<Provider store={store}> | ||
{() => ( | ||
<Connector select={string => ({ string })}> | ||
{({ string }) => <TestComp string={string} />} | ||
</Connector> | ||
)} | ||
</Provider> | ||
); | ||
expect(() => renderToString(el)).toNotThrow(); | ||
}); | ||
}); | ||
}); |
import expect from 'expect'; | ||
import jsdomReact from './jsdomReact'; | ||
import React, { PropTypes, Component } from 'react/addons'; | ||
import { createRedux } from '../../src'; | ||
import { createStore } from '../../src'; | ||
import { provide, Provider } from '../../src/react'; | ||
@@ -15,3 +15,3 @@ | ||
static contextTypes = { | ||
redux: PropTypes.object.isRequired | ||
store: PropTypes.object.isRequired | ||
} | ||
@@ -24,6 +24,6 @@ | ||
it('wraps component with Provider', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
it('should wrap the component into Provider', () => { | ||
const store = createStore({}); | ||
@provide(redux) | ||
@provide(store) | ||
class Container extends Component { | ||
@@ -35,12 +35,15 @@ render() { | ||
const container = TestUtils.renderIntoDocument(<Container pass="through" />); | ||
const container = TestUtils.renderIntoDocument( | ||
<Container pass='through' /> | ||
); | ||
const child = TestUtils.findRenderedComponentWithType(container, Child); | ||
expect(child.props.pass).toEqual('through'); | ||
expect(() => TestUtils.findRenderedComponentWithType(container, Provider)) | ||
.toNotThrow(); | ||
expect(child.context.redux).toBe(redux); | ||
expect(() => | ||
TestUtils.findRenderedComponentWithType(container, Provider) | ||
).toNotThrow(); | ||
expect(child.context.store).toBe(store); | ||
}); | ||
it('sets displayName correctly', () => { | ||
@provide(createRedux({ test: () => 'test' })) | ||
it('sets the displayName correctly', () => { | ||
@provide(createStore({})) | ||
class Container extends Component { | ||
@@ -55,3 +58,3 @@ render() { | ||
it('sets DecoratedComponent to wrapped component', () => { | ||
it('should expose the wrapped component as DecoratedComponent', () => { | ||
class Container extends Component { | ||
@@ -63,8 +66,8 @@ render() { | ||
let decorator = provide(state => state); | ||
let ProviderDecorator = decorator(Container); | ||
const decorator = provide(state => state); | ||
const decorated = decorator(Container); | ||
expect(ProviderDecorator.DecoratedComponent).toBe(Container); | ||
expect(decorated.DecoratedComponent).toBe(Container); | ||
}); | ||
}); | ||
}); |
import expect from 'expect'; | ||
import jsdomReact from './jsdomReact'; | ||
import React, { PropTypes, Component } from 'react/addons'; | ||
import { createRedux } from '../../src'; | ||
import { createStore } from '../../src'; | ||
import { Provider } from '../../src/react'; | ||
@@ -15,3 +15,3 @@ | ||
static contextTypes = { | ||
redux: PropTypes.object.isRequired | ||
store: PropTypes.object.isRequired | ||
} | ||
@@ -24,7 +24,7 @@ | ||
it('adds Redux to child context', () => { | ||
const redux = createRedux({ test: () => 'test' }); | ||
it('should add the store to the child context', () => { | ||
const store = createStore({}); | ||
const tree = TestUtils.renderIntoDocument( | ||
<Provider redux={redux}> | ||
<Provider store={store}> | ||
{() => <Child />} | ||
@@ -35,16 +35,16 @@ </Provider> | ||
const child = TestUtils.findRenderedComponentWithType(tree, Child); | ||
expect(child.context.redux).toBe(redux); | ||
expect(child.context.store).toBe(store); | ||
}); | ||
it('does not lose subscribers when receiving new props', () => { | ||
const redux1 = createRedux({ test: () => 'test' }); | ||
const redux2 = createRedux({ test: () => 'test' }); | ||
it('should replace just the reducer when receiving a new store in props', () => { | ||
const store1 = createStore((state = 10) => state + 1); | ||
const store2 = createStore((state = 10) => state * 2); | ||
const spy = expect.createSpy(() => {}); | ||
class ProviderContainer extends Component { | ||
state = { redux: redux1 }; | ||
state = { store: store1 }; | ||
render() { | ||
return ( | ||
<Provider redux={this.state.redux}> | ||
<Provider store={this.state.store}> | ||
{() => <Child />} | ||
@@ -58,13 +58,18 @@ </Provider> | ||
const child = TestUtils.findRenderedComponentWithType(container, Child); | ||
expect(child.context.store.getState()).toEqual(11); | ||
child.context.redux.subscribe(spy); | ||
child.context.redux.dispatch({}); | ||
child.context.store.subscribe(spy); | ||
child.context.store.dispatch({}); | ||
expect(spy.calls.length).toEqual(1); | ||
expect(child.context.store.getState()).toEqual(12); | ||
container.setState({ redux: redux2 }); | ||
container.setState({ store: store2 }); | ||
expect(spy.calls.length).toEqual(2); | ||
child.context.redux.dispatch({}); | ||
expect(child.context.store.getState()).toEqual(24); | ||
child.context.store.dispatch({}); | ||
expect(spy.calls.length).toEqual(3); | ||
expect(child.context.store.getState()).toEqual(48); | ||
}); | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ import expect from 'expect'; | ||
describe('composeMiddleware', () => { | ||
it('should return combined middleware that executes from left to right', () => { | ||
it('should return the combined middleware that executes from left to right', () => { | ||
const a = next => action => next(action + 'a'); | ||
@@ -9,0 +9,0 @@ const b = next => action => next(action + 'b'); |
import expect from 'expect'; | ||
import { createClass, Component } from 'react'; | ||
import getDisplayName from '../src/utils/getDisplayName'; | ||
@@ -6,8 +7,7 @@ | ||
describe('getDisplayName', () => { | ||
it('should ensure a name for the given component', () => { | ||
it('should extract the component class name', () => { | ||
const names = [ | ||
{ displayName: 'Foo'}, | ||
{ name: 'Bar' }, | ||
{} | ||
createClass({ displayName: 'Foo', render() {} }), | ||
class Bar extends Component {}, | ||
createClass({ render() {} }) | ||
].map(getDisplayName); | ||
@@ -14,0 +14,0 @@ |
import expect from 'expect'; | ||
import { bindActionCreators, createRedux } from '../../src'; | ||
import * as helpers from '../_helpers'; | ||
import { bindActionCreators, createStore } from '../../src'; | ||
import { todos } from '../helpers/reducers'; | ||
import * as actionCreators from '../helpers/actionCreators'; | ||
const { todoActions, todoStore } = helpers; | ||
describe('Utils', () => { | ||
describe('bindActionCreators', () => { | ||
let store; | ||
let redux; | ||
beforeEach(() => { | ||
redux = createRedux({ todoStore }); | ||
store = createStore(todos); | ||
}); | ||
it('should bind given actions to the dispatcher', done => { | ||
let expectedCallCount = 2; | ||
// just for monitoring the dispatched actions | ||
redux.subscribe(() => { | ||
expectedCallCount--; | ||
if (expectedCallCount === 0) { | ||
const state = redux.getState(); | ||
expect(state.todoStore).toEqual([ | ||
{ id: 2, text: 'World' }, | ||
{ id: 1, text: 'Hello' } | ||
]); | ||
done(); | ||
} | ||
}); | ||
const actions = bindActionCreators(todoActions, redux.dispatch); | ||
expect(Object.keys(actions)).toEqual(Object.keys(todoActions)); | ||
it('should wrap the action creators with the dispatch function', () => { | ||
const boundActionCreators = bindActionCreators(actionCreators, store.dispatch); | ||
expect( | ||
Object.keys(boundActionCreators) | ||
).toEqual( | ||
Object.keys(actionCreators) | ||
); | ||
actions.addTodo('Hello'); | ||
actions.addTodoAsync('World'); | ||
const action = boundActionCreators.addTodo('Hello'); | ||
expect(action).toEqual( | ||
actionCreators.addTodo('Hello') | ||
); | ||
expect(store.getState()).toEqual([ | ||
{ id: 1, text: 'Hello' } | ||
]); | ||
}); | ||
}); | ||
}); |
@@ -6,4 +6,4 @@ import expect from 'expect'; | ||
describe('identity', () => { | ||
it('should return first argument passed to it', () => { | ||
const test = { 'a': 1 }; | ||
it('should return the first argument passed to it', () => { | ||
const test = { a: 1 }; | ||
expect(identity(test, 'test')).toBe(test); | ||
@@ -10,0 +10,0 @@ }); |
@@ -7,4 +7,10 @@ import expect from 'expect'; | ||
it('should return object with mapped values', () => { | ||
const test = { 'a': 'c', 'b': 'd' }; | ||
expect(mapValues(test, (val, key) => val + key)).toEqual({ 'a': 'ca', 'b': 'db' }); | ||
const test = { | ||
a: 'c', | ||
b: 'd' | ||
}; | ||
expect(mapValues(test, (val, key) => val + key)).toEqual({ | ||
a: 'ca', | ||
b: 'db' | ||
}); | ||
}); | ||
@@ -11,0 +17,0 @@ }); |
@@ -7,6 +7,13 @@ import expect from 'expect'; | ||
it('should return object with picked values', () => { | ||
const test = { 'name': 'lily', 'age': 20 }; | ||
expect(pick(test, x => typeof x === 'string')).toEqual({ 'name': 'lily' }); | ||
const test = { | ||
name: 'lily', | ||
age: 20 | ||
}; | ||
expect( | ||
pick(test, x => typeof x === 'string') | ||
).toEqual({ | ||
name: 'lily' | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ import expect from 'expect'; | ||
describe('shallowEqualScalar', () => { | ||
it('returns true if both arguments are the same object', () => { | ||
it('should return true if both arguments are the same object', () => { | ||
const o = { a: 1, b: 2 }; | ||
@@ -14,3 +14,3 @@ expect(shallowEqualScalar(o, o)).toBe(true); | ||
it('returns false if either argument is null', () => { | ||
it('should return false if either argument is null', () => { | ||
expect(shallowEqualScalar(null, {})).toBe(false); | ||
@@ -20,3 +20,3 @@ expect(shallowEqualScalar({}, null)).toBe(false); | ||
it('returns true if arguments fields are equal', () => { | ||
it('should return true if arguments fields are equal', () => { | ||
expect( | ||
@@ -37,3 +37,3 @@ shallowEqualScalar( | ||
it('returns false if first argument has too many keys', () => { | ||
it('should return false if first argument has too many keys', () => { | ||
expect( | ||
@@ -47,3 +47,3 @@ shallowEqualScalar( | ||
it('returns false if second argument has too many keys', () => { | ||
it('should return false if second argument has too many keys', () => { | ||
expect( | ||
@@ -57,3 +57,3 @@ shallowEqualScalar( | ||
it('returns false if arguments have keys dont have same value', () => { | ||
it('should return false if arguments have keys dont have same value', () => { | ||
expect( | ||
@@ -67,3 +67,3 @@ shallowEqualScalar( | ||
it('returns false if arguments have field that are objects', () => { | ||
it('should return false if arguments have field that are objects', () => { | ||
const o = {}; | ||
@@ -78,3 +78,3 @@ expect( | ||
it('returns false if arguments have different keys', () => { | ||
it('should return false if arguments have different keys', () => { | ||
expect( | ||
@@ -90,3 +90,3 @@ shallowEqualScalar( | ||
describe('shallowEqual', () => { | ||
it('returns true if arguments fields are equal', () => { | ||
it('should return true if arguments fields are equal', () => { | ||
expect( | ||
@@ -115,3 +115,3 @@ shallowEqual( | ||
it('returns false if first argument has too many keys', () => { | ||
it('should return false if first argument has too many keys', () => { | ||
expect( | ||
@@ -125,3 +125,3 @@ shallowEqual( | ||
it('returns false if second argument has too many keys', () => { | ||
it('should return false if second argument has too many keys', () => { | ||
expect( | ||
@@ -135,3 +135,3 @@ shallowEqual( | ||
it('returns false if arguments have different keys', () => { | ||
it('should return false if arguments have different keys', () => { | ||
expect( | ||
@@ -145,3 +145,2 @@ shallowEqual( | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245453
77
3100
487