Skip to content

Instantly share code, notes, and snippets.

View stephenparish's full-sized avatar

Stephen Parish stephenparish

View GitHub Profile
@stephenparish
stephenparish / mini-redux.js
Last active December 12, 2019 02:44 — forked from MarcoWorms/mini-redux.js
Redux in a nutshell
function createStore (reducers) {
let state = reducers()
const subscribers = [];
const store = {
dispatch: (action) => {
state = reducers(state, action);
subscribers.forEach((subscriber) => subscriber());
},
getState: () => {
return state