Loading homepage
Implement a small Redux-style store with reducer-driven state, synchronous dispatch, and subscriptions.
Input: const store = createStore((state = 0, action) => action.type === "increment" ? state + 1 : state); const unsubscribe = store.subscribe(() => console.log(store.getState())); store.dispatch({ type: "increment" }); unsubscribe(); Output: State is 1; the listener ran once.
Input: store.getState(); Output: Returns the current state synchronously.
Implement the exported function in index.js or index.ts. Tests provide fixtures for the required behavior.