This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export { | |
| createStore, | |
| combineReducers, | |
| bindActionCreators, | |
| applyMiddleware, | |
| compose | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function createStore(reducer, preloadedState, enhancer) { | |
| ... | |
| return { | |
| dispatch, | |
| subscribe, | |
| getState, | |
| replaceReducer, | |
| [$$observable]: observable | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let currentReducer = reducer | |
| let currentState = preloadedState | |
| let currentListeners = [] | |
| let nextListeners = currentListeners | |
| let isDispatching = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare type Reducer<S, A> = (state: S, action: A) => S; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore } from 'redux'; // CommonJS: const createStore = require('redux')['createStore'] | |
| const app = createStore((state, action) => { return state }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createStore } from 'redux'; | |
| const app = createStore((state, action) => { return state }, { booted_at: new Date() }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function createStore(reducer, preloadedState) { | |
| let state = preloadedState | |
| let listeners = [] | |
| let dispatching = false | |
| function getState() { | |
| return state | |
| } | |
| function dispatch(action) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| let currentState = preloadedState | |
| ... | |
| function getState() { | |
| return currentState | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function dispatch(action) { | |
| if (!isPlainObject(action)) { | |
| throw new Error( | |
| 'Actions must be plain objects. ' + | |
| 'Use custom middleware for async actions.' | |
| ) | |
| } | |
| if (typeof action.type === 'undefined') { | |
| throw new Error( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare type Dispatch<A: { type: $Subtype<string> }> = (action: A) => A; |