|
1 | 1 | import isPlainObject from './utils/isPlainObject'
|
2 |
| -import compose from './compose' |
3 | 2 |
|
4 | 3 | /**
|
5 | 4 | * These are private action types reserved by Redux.
|
@@ -28,16 +27,26 @@ export var ActionTypes = {
|
28 | 27 | * If you use `combineReducers` to produce the root reducer function, this must be
|
29 | 28 | * an object with the same shape as `combineReducers` keys.
|
30 | 29 | *
|
| 30 | + * @param {Function} enhancer The store enhancer. You may optionally specify it |
| 31 | + * to enhance the store with third-party capabilities such as the middleware, |
| 32 | + * time travel, persistence, etc. The only store enhancer that ships with Redux |
| 33 | + * is `applyMiddleware()`. |
| 34 | + * |
31 | 35 | * @returns {Store} A Redux store that lets you read the state, dispatch actions
|
32 | 36 | * and subscribe to changes.
|
33 | 37 | */
|
34 |
| -export default function createStore(reducer, initialState, ...enhancers) { |
35 |
| - if (typeof initialState === 'function') { |
36 |
| - enhancers.unshift(initialState) |
| 38 | +export default function createStore(reducer, initialState, enhancer) { |
| 39 | + if (typeof initialState === 'function' && typeof enhancer === 'undefined') { |
| 40 | + enhancer = initialState |
37 | 41 | initialState = undefined
|
38 | 42 | }
|
39 |
| - if (enhancers.length > 0) { |
40 |
| - return compose(...enhancers)(createStore)(reducer, initialState) |
| 43 | + |
| 44 | + if (typeof enhancer !== 'undefined') { |
| 45 | + if (typeof enhancer !== 'function') { |
| 46 | + throw new Error('Expected the enhancer to be a function.') |
| 47 | + } |
| 48 | + |
| 49 | + return enhancer(createStore)(reducer, initialState) |
41 | 50 | }
|
42 | 51 |
|
43 | 52 | if (typeof reducer !== 'function') {
|
|
0 commit comments