Track
Thetrack module gives you a compact reactive state primitive inspired by signal-style APIs. A state returns a getter and setter. Effects subscribe to one or more getters and run when a subscribed state changes.
State and effect
Effects are dependency based. Updating a different state will not trigger an effect unless that state’s getter is included in the dependency list.
Tables and functional updates
When the initial value, returned value, or next value is a table, sure_lib deep-clones it at the state boundary. This prevents accidental mutation of stored state through an old table reference.API
function
required
Creates a reactive state.
stateName is used internally to connect dependencies to effects.function
Call the getter with no arguments to read the current value:
amount().function
Call the setter with a new value or a function
(currentValue) -> nextValue to update state and notify dependent effects.function
required
Registers a callback that runs when any getter in
dependencies changes.