0.0.46 • Published 12 months ago

crystalline-state v0.0.46

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

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: () => {},
 },
});
0.0.46

12 months ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.3

1 year ago

0.0.43

1 year ago

0.0.2

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.4

1 year ago

0.0.1

2 years ago