redux.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. import $$observable from 'symbol-observable';
  2. /**
  3. * These are private action types reserved by Redux.
  4. * For any unknown actions, you must return the current state.
  5. * If the current state is undefined, you must return the initial state.
  6. * Do not reference these action types directly in your code.
  7. */
  8. var randomString = function randomString() {
  9. return Math.random().toString(36).substring(7).split('').join('.');
  10. };
  11. var ActionTypes = {
  12. INIT: "@@redux/INIT" + randomString(),
  13. REPLACE: "@@redux/REPLACE" + randomString(),
  14. PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
  15. return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
  16. }
  17. };
  18. /**
  19. * @param {any} obj The object to inspect.
  20. * @returns {boolean} True if the argument appears to be a plain object.
  21. */
  22. function isPlainObject(obj) {
  23. if (typeof obj !== 'object' || obj === null) return false;
  24. var proto = obj;
  25. while (Object.getPrototypeOf(proto) !== null) {
  26. proto = Object.getPrototypeOf(proto);
  27. }
  28. return Object.getPrototypeOf(obj) === proto;
  29. }
  30. /**
  31. * Creates a Redux store that holds the state tree.
  32. * The only way to change the data in the store is to call `dispatch()` on it.
  33. *
  34. * There should only be a single store in your app. To specify how different
  35. * parts of the state tree respond to actions, you may combine several reducers
  36. * into a single reducer function by using `combineReducers`.
  37. *
  38. * @param {Function} reducer A function that returns the next state tree, given
  39. * the current state tree and the action to handle.
  40. *
  41. * @param {any} [preloadedState] The initial state. You may optionally specify it
  42. * to hydrate the state from the server in universal apps, or to restore a
  43. * previously serialized user session.
  44. * If you use `combineReducers` to produce the root reducer function, this must be
  45. * an object with the same shape as `combineReducers` keys.
  46. *
  47. * @param {Function} [enhancer] The store enhancer. You may optionally specify it
  48. * to enhance the store with third-party capabilities such as middleware,
  49. * time travel, persistence, etc. The only store enhancer that ships with Redux
  50. * is `applyMiddleware()`.
  51. *
  52. * @returns {Store} A Redux store that lets you read the state, dispatch actions
  53. * and subscribe to changes.
  54. */
  55. function createStore(reducer, preloadedState, enhancer) {
  56. var _ref2;
  57. if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
  58. throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.');
  59. }
  60. if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
  61. enhancer = preloadedState;
  62. preloadedState = undefined;
  63. }
  64. if (typeof enhancer !== 'undefined') {
  65. if (typeof enhancer !== 'function') {
  66. throw new Error('Expected the enhancer to be a function.');
  67. }
  68. return enhancer(createStore)(reducer, preloadedState);
  69. }
  70. if (typeof reducer !== 'function') {
  71. throw new Error('Expected the reducer to be a function.');
  72. }
  73. var currentReducer = reducer;
  74. var currentState = preloadedState;
  75. var currentListeners = [];
  76. var nextListeners = currentListeners;
  77. var isDispatching = false;
  78. /**
  79. * This makes a shallow copy of currentListeners so we can use
  80. * nextListeners as a temporary list while dispatching.
  81. *
  82. * This prevents any bugs around consumers calling
  83. * subscribe/unsubscribe in the middle of a dispatch.
  84. */
  85. function ensureCanMutateNextListeners() {
  86. if (nextListeners === currentListeners) {
  87. nextListeners = currentListeners.slice();
  88. }
  89. }
  90. /**
  91. * Reads the state tree managed by the store.
  92. *
  93. * @returns {any} The current state tree of your application.
  94. */
  95. function getState() {
  96. if (isDispatching) {
  97. throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
  98. }
  99. return currentState;
  100. }
  101. /**
  102. * Adds a change listener. It will be called any time an action is dispatched,
  103. * and some part of the state tree may potentially have changed. You may then
  104. * call `getState()` to read the current state tree inside the callback.
  105. *
  106. * You may call `dispatch()` from a change listener, with the following
  107. * caveats:
  108. *
  109. * 1. The subscriptions are snapshotted just before every `dispatch()` call.
  110. * If you subscribe or unsubscribe while the listeners are being invoked, this
  111. * will not have any effect on the `dispatch()` that is currently in progress.
  112. * However, the next `dispatch()` call, whether nested or not, will use a more
  113. * recent snapshot of the subscription list.
  114. *
  115. * 2. The listener should not expect to see all state changes, as the state
  116. * might have been updated multiple times during a nested `dispatch()` before
  117. * the listener is called. It is, however, guaranteed that all subscribers
  118. * registered before the `dispatch()` started will be called with the latest
  119. * state by the time it exits.
  120. *
  121. * @param {Function} listener A callback to be invoked on every dispatch.
  122. * @returns {Function} A function to remove this change listener.
  123. */
  124. function subscribe(listener) {
  125. if (typeof listener !== 'function') {
  126. throw new Error('Expected the listener to be a function.');
  127. }
  128. if (isDispatching) {
  129. throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
  130. }
  131. var isSubscribed = true;
  132. ensureCanMutateNextListeners();
  133. nextListeners.push(listener);
  134. return function unsubscribe() {
  135. if (!isSubscribed) {
  136. return;
  137. }
  138. if (isDispatching) {
  139. throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
  140. }
  141. isSubscribed = false;
  142. ensureCanMutateNextListeners();
  143. var index = nextListeners.indexOf(listener);
  144. nextListeners.splice(index, 1);
  145. currentListeners = null;
  146. };
  147. }
  148. /**
  149. * Dispatches an action. It is the only way to trigger a state change.
  150. *
  151. * The `reducer` function, used to create the store, will be called with the
  152. * current state tree and the given `action`. Its return value will
  153. * be considered the **next** state of the tree, and the change listeners
  154. * will be notified.
  155. *
  156. * The base implementation only supports plain object actions. If you want to
  157. * dispatch a Promise, an Observable, a thunk, or something else, you need to
  158. * wrap your store creating function into the corresponding middleware. For
  159. * example, see the documentation for the `redux-thunk` package. Even the
  160. * middleware will eventually dispatch plain object actions using this method.
  161. *
  162. * @param {Object} action A plain object representing “what changed”. It is
  163. * a good idea to keep actions serializable so you can record and replay user
  164. * sessions, or use the time travelling `redux-devtools`. An action must have
  165. * a `type` property which may not be `undefined`. It is a good idea to use
  166. * string constants for action types.
  167. *
  168. * @returns {Object} For convenience, the same action object you dispatched.
  169. *
  170. * Note that, if you use a custom middleware, it may wrap `dispatch()` to
  171. * return something else (for example, a Promise you can await).
  172. */
  173. function dispatch(action) {
  174. if (!isPlainObject(action)) {
  175. throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
  176. }
  177. if (typeof action.type === 'undefined') {
  178. throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
  179. }
  180. if (isDispatching) {
  181. throw new Error('Reducers may not dispatch actions.');
  182. }
  183. try {
  184. isDispatching = true;
  185. currentState = currentReducer(currentState, action);
  186. } finally {
  187. isDispatching = false;
  188. }
  189. var listeners = currentListeners = nextListeners;
  190. for (var i = 0; i < listeners.length; i++) {
  191. var listener = listeners[i];
  192. listener();
  193. }
  194. return action;
  195. }
  196. /**
  197. * Replaces the reducer currently used by the store to calculate the state.
  198. *
  199. * You might need this if your app implements code splitting and you want to
  200. * load some of the reducers dynamically. You might also need this if you
  201. * implement a hot reloading mechanism for Redux.
  202. *
  203. * @param {Function} nextReducer The reducer for the store to use instead.
  204. * @returns {void}
  205. */
  206. function replaceReducer(nextReducer) {
  207. if (typeof nextReducer !== 'function') {
  208. throw new Error('Expected the nextReducer to be a function.');
  209. }
  210. currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
  211. // Any reducers that existed in both the new and old rootReducer
  212. // will receive the previous state. This effectively populates
  213. // the new state tree with any relevant data from the old one.
  214. dispatch({
  215. type: ActionTypes.REPLACE
  216. });
  217. }
  218. /**
  219. * Interoperability point for observable/reactive libraries.
  220. * @returns {observable} A minimal observable of state changes.
  221. * For more information, see the observable proposal:
  222. * https://github.com/tc39/proposal-observable
  223. */
  224. function observable() {
  225. var _ref;
  226. var outerSubscribe = subscribe;
  227. return _ref = {
  228. /**
  229. * The minimal observable subscription method.
  230. * @param {Object} observer Any object that can be used as an observer.
  231. * The observer object should have a `next` method.
  232. * @returns {subscription} An object with an `unsubscribe` method that can
  233. * be used to unsubscribe the observable from the store, and prevent further
  234. * emission of values from the observable.
  235. */
  236. subscribe: function subscribe(observer) {
  237. if (typeof observer !== 'object' || observer === null) {
  238. throw new TypeError('Expected the observer to be an object.');
  239. }
  240. function observeState() {
  241. if (observer.next) {
  242. observer.next(getState());
  243. }
  244. }
  245. observeState();
  246. var unsubscribe = outerSubscribe(observeState);
  247. return {
  248. unsubscribe: unsubscribe
  249. };
  250. }
  251. }, _ref[$$observable] = function () {
  252. return this;
  253. }, _ref;
  254. } // When a store is created, an "INIT" action is dispatched so that every
  255. // reducer returns their initial state. This effectively populates
  256. // the initial state tree.
  257. dispatch({
  258. type: ActionTypes.INIT
  259. });
  260. return _ref2 = {
  261. dispatch: dispatch,
  262. subscribe: subscribe,
  263. getState: getState,
  264. replaceReducer: replaceReducer
  265. }, _ref2[$$observable] = observable, _ref2;
  266. }
  267. /**
  268. * Prints a warning in the console if it exists.
  269. *
  270. * @param {String} message The warning message.
  271. * @returns {void}
  272. */
  273. function warning(message) {
  274. /* eslint-disable no-console */
  275. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  276. console.error(message);
  277. }
  278. /* eslint-enable no-console */
  279. try {
  280. // This error was thrown as a convenience so that if you enable
  281. // "break on all exceptions" in your console,
  282. // it would pause the execution at this line.
  283. throw new Error(message);
  284. } catch (e) {} // eslint-disable-line no-empty
  285. }
  286. function getUndefinedStateErrorMessage(key, action) {
  287. var actionType = action && action.type;
  288. var actionDescription = actionType && "action \"" + String(actionType) + "\"" || 'an action';
  289. return "Given " + actionDescription + ", reducer \"" + key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.";
  290. }
  291. function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
  292. var reducerKeys = Object.keys(reducers);
  293. var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
  294. if (reducerKeys.length === 0) {
  295. return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
  296. }
  297. if (!isPlainObject(inputState)) {
  298. return "The " + argumentName + " has unexpected type of \"" + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
  299. }
  300. var unexpectedKeys = Object.keys(inputState).filter(function (key) {
  301. return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
  302. });
  303. unexpectedKeys.forEach(function (key) {
  304. unexpectedKeyCache[key] = true;
  305. });
  306. if (action && action.type === ActionTypes.REPLACE) return;
  307. if (unexpectedKeys.length > 0) {
  308. return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
  309. }
  310. }
  311. function assertReducerShape(reducers) {
  312. Object.keys(reducers).forEach(function (key) {
  313. var reducer = reducers[key];
  314. var initialState = reducer(undefined, {
  315. type: ActionTypes.INIT
  316. });
  317. if (typeof initialState === 'undefined') {
  318. throw new Error("Reducer \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
  319. }
  320. if (typeof reducer(undefined, {
  321. type: ActionTypes.PROBE_UNKNOWN_ACTION()
  322. }) === 'undefined') {
  323. throw new Error("Reducer \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle " + ActionTypes.INIT + " or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
  324. }
  325. });
  326. }
  327. /**
  328. * Turns an object whose values are different reducer functions, into a single
  329. * reducer function. It will call every child reducer, and gather their results
  330. * into a single state object, whose keys correspond to the keys of the passed
  331. * reducer functions.
  332. *
  333. * @param {Object} reducers An object whose values correspond to different
  334. * reducer functions that need to be combined into one. One handy way to obtain
  335. * it is to use ES6 `import * as reducers` syntax. The reducers may never return
  336. * undefined for any action. Instead, they should return their initial state
  337. * if the state passed to them was undefined, and the current state for any
  338. * unrecognized action.
  339. *
  340. * @returns {Function} A reducer function that invokes every reducer inside the
  341. * passed object, and builds a state object with the same shape.
  342. */
  343. function combineReducers(reducers) {
  344. var reducerKeys = Object.keys(reducers);
  345. var finalReducers = {};
  346. for (var i = 0; i < reducerKeys.length; i++) {
  347. var key = reducerKeys[i];
  348. if (process.env.NODE_ENV !== 'production') {
  349. if (typeof reducers[key] === 'undefined') {
  350. warning("No reducer provided for key \"" + key + "\"");
  351. }
  352. }
  353. if (typeof reducers[key] === 'function') {
  354. finalReducers[key] = reducers[key];
  355. }
  356. }
  357. var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
  358. // keys multiple times.
  359. var unexpectedKeyCache;
  360. if (process.env.NODE_ENV !== 'production') {
  361. unexpectedKeyCache = {};
  362. }
  363. var shapeAssertionError;
  364. try {
  365. assertReducerShape(finalReducers);
  366. } catch (e) {
  367. shapeAssertionError = e;
  368. }
  369. return function combination(state, action) {
  370. if (state === void 0) {
  371. state = {};
  372. }
  373. if (shapeAssertionError) {
  374. throw shapeAssertionError;
  375. }
  376. if (process.env.NODE_ENV !== 'production') {
  377. var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
  378. if (warningMessage) {
  379. warning(warningMessage);
  380. }
  381. }
  382. var hasChanged = false;
  383. var nextState = {};
  384. for (var _i = 0; _i < finalReducerKeys.length; _i++) {
  385. var _key = finalReducerKeys[_i];
  386. var reducer = finalReducers[_key];
  387. var previousStateForKey = state[_key];
  388. var nextStateForKey = reducer(previousStateForKey, action);
  389. if (typeof nextStateForKey === 'undefined') {
  390. var errorMessage = getUndefinedStateErrorMessage(_key, action);
  391. throw new Error(errorMessage);
  392. }
  393. nextState[_key] = nextStateForKey;
  394. hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
  395. }
  396. hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
  397. return hasChanged ? nextState : state;
  398. };
  399. }
  400. function bindActionCreator(actionCreator, dispatch) {
  401. return function () {
  402. return dispatch(actionCreator.apply(this, arguments));
  403. };
  404. }
  405. /**
  406. * Turns an object whose values are action creators, into an object with the
  407. * same keys, but with every function wrapped into a `dispatch` call so they
  408. * may be invoked directly. This is just a convenience method, as you can call
  409. * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
  410. *
  411. * For convenience, you can also pass an action creator as the first argument,
  412. * and get a dispatch wrapped function in return.
  413. *
  414. * @param {Function|Object} actionCreators An object whose values are action
  415. * creator functions. One handy way to obtain it is to use ES6 `import * as`
  416. * syntax. You may also pass a single function.
  417. *
  418. * @param {Function} dispatch The `dispatch` function available on your Redux
  419. * store.
  420. *
  421. * @returns {Function|Object} The object mimicking the original object, but with
  422. * every action creator wrapped into the `dispatch` call. If you passed a
  423. * function as `actionCreators`, the return value will also be a single
  424. * function.
  425. */
  426. function bindActionCreators(actionCreators, dispatch) {
  427. if (typeof actionCreators === 'function') {
  428. return bindActionCreator(actionCreators, dispatch);
  429. }
  430. if (typeof actionCreators !== 'object' || actionCreators === null) {
  431. throw new Error("bindActionCreators expected an object or a function, instead received " + (actionCreators === null ? 'null' : typeof actionCreators) + ". " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
  432. }
  433. var boundActionCreators = {};
  434. for (var key in actionCreators) {
  435. var actionCreator = actionCreators[key];
  436. if (typeof actionCreator === 'function') {
  437. boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  438. }
  439. }
  440. return boundActionCreators;
  441. }
  442. function _defineProperty(obj, key, value) {
  443. if (key in obj) {
  444. Object.defineProperty(obj, key, {
  445. value: value,
  446. enumerable: true,
  447. configurable: true,
  448. writable: true
  449. });
  450. } else {
  451. obj[key] = value;
  452. }
  453. return obj;
  454. }
  455. function ownKeys(object, enumerableOnly) {
  456. var keys = Object.keys(object);
  457. if (Object.getOwnPropertySymbols) {
  458. keys.push.apply(keys, Object.getOwnPropertySymbols(object));
  459. }
  460. if (enumerableOnly) keys = keys.filter(function (sym) {
  461. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  462. });
  463. return keys;
  464. }
  465. function _objectSpread2(target) {
  466. for (var i = 1; i < arguments.length; i++) {
  467. var source = arguments[i] != null ? arguments[i] : {};
  468. if (i % 2) {
  469. ownKeys(source, true).forEach(function (key) {
  470. _defineProperty(target, key, source[key]);
  471. });
  472. } else if (Object.getOwnPropertyDescriptors) {
  473. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  474. } else {
  475. ownKeys(source).forEach(function (key) {
  476. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  477. });
  478. }
  479. }
  480. return target;
  481. }
  482. /**
  483. * Composes single-argument functions from right to left. The rightmost
  484. * function can take multiple arguments as it provides the signature for
  485. * the resulting composite function.
  486. *
  487. * @param {...Function} funcs The functions to compose.
  488. * @returns {Function} A function obtained by composing the argument functions
  489. * from right to left. For example, compose(f, g, h) is identical to doing
  490. * (...args) => f(g(h(...args))).
  491. */
  492. function compose() {
  493. for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
  494. funcs[_key] = arguments[_key];
  495. }
  496. if (funcs.length === 0) {
  497. return function (arg) {
  498. return arg;
  499. };
  500. }
  501. if (funcs.length === 1) {
  502. return funcs[0];
  503. }
  504. return funcs.reduce(function (a, b) {
  505. return function () {
  506. return a(b.apply(void 0, arguments));
  507. };
  508. });
  509. }
  510. /**
  511. * Creates a store enhancer that applies middleware to the dispatch method
  512. * of the Redux store. This is handy for a variety of tasks, such as expressing
  513. * asynchronous actions in a concise manner, or logging every action payload.
  514. *
  515. * See `redux-thunk` package as an example of the Redux middleware.
  516. *
  517. * Because middleware is potentially asynchronous, this should be the first
  518. * store enhancer in the composition chain.
  519. *
  520. * Note that each middleware will be given the `dispatch` and `getState` functions
  521. * as named arguments.
  522. *
  523. * @param {...Function} middlewares The middleware chain to be applied.
  524. * @returns {Function} A store enhancer applying the middleware.
  525. */
  526. function applyMiddleware() {
  527. for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
  528. middlewares[_key] = arguments[_key];
  529. }
  530. return function (createStore) {
  531. return function () {
  532. var store = createStore.apply(void 0, arguments);
  533. var _dispatch = function dispatch() {
  534. throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
  535. };
  536. var middlewareAPI = {
  537. getState: store.getState,
  538. dispatch: function dispatch() {
  539. return _dispatch.apply(void 0, arguments);
  540. }
  541. };
  542. var chain = middlewares.map(function (middleware) {
  543. return middleware(middlewareAPI);
  544. });
  545. _dispatch = compose.apply(void 0, chain)(store.dispatch);
  546. return _objectSpread2({}, store, {
  547. dispatch: _dispatch
  548. });
  549. };
  550. };
  551. }
  552. /*
  553. * This is a dummy function to check if the function name has been altered by minification.
  554. * If the function has been minified and NODE_ENV !== 'production', warn the user.
  555. */
  556. function isCrushed() {}
  557. if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
  558. warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
  559. }
  560. export { ActionTypes as __DO_NOT_USE__ActionTypes, applyMiddleware, bindActionCreators, combineReducers, compose, createStore };