0.0.46 • Published 12 months ago
crystalline-state v0.0.46
This is a simple TypeScript library for a state management.
State Object
import { CreateState } from "crystalline-state";
export const [stateEvents, state] = CreateState({
screen: "",
});
stateEvents("screen", "get", () =>{});
stateEvents("screen", "set", () =>{});
stateEvents("screen", "change", () =>{});
state.screen = "main";
State Machine
import { CreateMachine } from "crystalline-state";
const machine = CreateMachine({
IDLE: {
LOAD: {
args: { data: {} },
goTo: "INIT",
},
},
INIT: {
LOAD: {
goTo: "IDLE",
},
},
});
machine.addToEvent("IDLE", "LOAD", (args) => {
console.log(args.data);
});
machine.triggerEvent("IDLE", "LOAD", { data: {} });
machine.addToStates({
IDLE: {
LOAD: () => {},
},
});