Just released v3.0 of @small-tech/state
(A tiny – 42 lines of code¹ – JavaScript state management class.)
https://codeberg.org/small-tech/state
The state class is no longer a proxy itself but instead uses a proxy to guard access/update of states. This means instances/subclasses of State can now be persisted in JavaScript Database (JSDB)² objects. e.g., for use in Kitten³ apps.
¹ Sans comments and empty lines.
² https://codeberg.org/small-tech/jsdb
³ https://codeberg.org/kitten/app
@aral I reflexively started reading after the first link and it took until the second line to figure out of this was tech or politics :)
@aral ...is this the JS equivalent of a Rust enum?
@moffintosh It’s definitely heavier than that and specialised for very basic state management with basic guards. But it is a class and is meant to be subclassed to be used. (The states object I’m passing in in the example is about as close as you get to enums in JS. TypeScript has the concept but JS does not – although, if I remember correctly, the keyword is reserved so maybe in the future…)