1
2
3
4
5
6
7
8
9
import { setItem } from "https://esm.town/v/beneskildsen/setItem";
import { getItem } from "https://esm.town/v/beneskildsen/getItem";
export const dispatch = async (action, reducer, stateNamespace) => {
const state = getItem(stateNamespace);
const nextState = reducer(state, action);
await setItem(stateNamespace, nextState);
return nextState;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023