( reducer: Reducer<S, A, PreloadedState>, preloadedState?: PreloadedState | StoreEnhancer<Ext, StateExt> | undefined, enhancer?: StoreEnhancer<Ext, StateExt> )
| 85 | enhancer?: StoreEnhancer<Ext, StateExt> |
| 86 | ): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext |
| 87 | export function createStore< |
| 88 | S, |
| 89 | A extends Action, |
| 90 | Ext extends {} = {}, |
| 91 | StateExt extends {} = {}, |
| 92 | PreloadedState = S |
| 93 | >( |
| 94 | reducer: Reducer<S, A, PreloadedState>, |
| 95 | preloadedState?: PreloadedState | StoreEnhancer<Ext, StateExt> | undefined, |
| 96 | enhancer?: StoreEnhancer<Ext, StateExt> |
| 97 | ): Store<S, A, UnknownIfNonSpecific<StateExt>> & Ext { |
| 98 | if (typeof reducer !== class="st">'function') { |
| 99 | throw new Error( |
| 100 | `Expected the root reducer to be a function. Instead, received: '${kindOf( |
| 101 | reducer |
| 102 | )}'` |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | if ( |
| 107 | (typeof preloadedState === class="st">'function' && typeof enhancer === class="st">'function') || |
| 108 | (typeof enhancer === class="st">'function' && typeof arguments[3] === class="st">'function') |
| 109 | ) { |
| 110 | throw new Error( |
| 111 | class="st">'It looks like you are passing several store enhancers to ' + |
| 112 | class="st">'createStore(). This is not supported. Instead, compose them ' + |
| 113 | class="st">'together to a single function. See https:class="cm">//redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.' |
| 114 | ) |
| 115 | } |
| 116 | |
| 117 | if (typeof preloadedState === class="st">'function' && typeof enhancer === class="st">'undefined') { |
| 118 | enhancer = preloadedState as StoreEnhancer<Ext, StateExt> |
| 119 | preloadedState = undefined |
| 120 | } |
| 121 | |
| 122 | if (typeof enhancer !== class="st">'undefined') { |
| 123 | if (typeof enhancer !== class="st">'function') { |
| 124 | throw new Error( |
| 125 | `Expected the enhancer to be a function. Instead, received: '${kindOf( |
| 126 | enhancer |
| 127 | )}'` |
| 128 | ) |
| 129 | } |
| 130 | |
| 131 | return enhancer(createStore)( |
| 132 | reducer, |
| 133 | preloadedState as PreloadedState | undefined |
| 134 | ) |
| 135 | } |
| 136 | |
| 137 | let currentReducer = reducer |
| 138 | let currentState: S | PreloadedState | undefined = preloadedState as |
| 139 | | PreloadedState |
| 140 | | undefined |
| 141 | let currentListeners: Map<number, ListenerCallback> | null = new Map() |
| 142 | let nextListeners = currentListeners |
| 143 | let listenerIdCounter = 0 |
| 144 | let isDispatching = false |
no test coverage detected