#1026 overall
Implementing the Store from Scratch (Redux)
egghead.io
1 recommender · 1 thread · recommended in 1 year, 2018 · score 0.7
A short egghead.io lesson by Dan Abramov in which he builds a minimal version of Redux's createStore from scratch, covering state, dispatch, subscribe and unsubscribe.
One commenter calls it an excellent course and says it shows the core of Redux in code simple enough to post in a comment.
Recommendations by year
20062026
In Dan Abramov's excellent egghead redux course [0] he implements the `createStore` from scratch which is the core of redux, it's simple enough to post here:
const createStore = (reducer) => { let state; let listeners = [];
const getState = () => state;
const dispatch = (action) => { state = reducer(state, action); listeners.map(listener => listener()); };
const subscribe = (listener) => { listeners.push(listener); // unsubscribe return () => { listeners = listeners.filter(l => l !== listener) }; };
// populate initial state dispatch({});
return { getState, dispatch, subscribe }; };
[0]: https://egghead.io/lessons/react-redux-implementing-store-fr...