Re:Step by Step Guide to Building React Redux Apps
by honua on Saturday February 27, 2016 @10:21PM
(#11189673)
Not counting other parts of its API like combineReducers and subscribing listeners, Redux is essentially..
function createStore(reducer, initialState) {
let state = initialState;
return {
dispatch(action) {
state = reducer(state, action);
},
getState() {
return state;
}
}
}
It's quite simple.. and yes, it should only be used when needed, but the whole implementation of the Redux part of an app can exist in a few lines in a single file.
function createStore(reducer, initialState) { let state = initialState; return { dispatch(action) { state = reducer(state, action); }, getState() { return state; } } }
It's quite simple.. and yes, it should only be used when needed, but the whole implementation of the Redux part of an app can exist in a few lines in a single file.