Lesson 26 — Ultimate: reactive store
Boss level: a store that announces changes
A store holds the app's state in one place. You never change state directly; you dispatch an action (a message like "inc"), a reducer function computes the new state from the old state and the action, and every subscriber is told about the new state. This is the idea behind Redux and Vue's reactivity.
const counter = (s, a) => (a === "inc" ? s + 1 : s);
counter(0, "inc"); // 1 — the reducer only computes, it never stores
Why it matters: one predictable path for every change makes big UIs debuggable.
Finish dispatch(): compute the new state with the reducer, then call every subscriber with it.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based JavaScript Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for JavaScript Foundations books — check the publication year so the examples match current versions.
Search Amazon →