Runes for state are primitives. They provide a concise syntax for local reactivity. However, when we
send these state primitives across boundaries (e.g. in function arguments), the state loses it's
reactivity and becomes a static value.
Boxes provide several utilities to make passing reactive state across boundaries easier.
Usage
box
Initializes a writable boxed state.
box.with
Creates reactive state using getter and setter functions. If a setter function is provided, the box
is writable. If not, the box is readonly.
Useful for passing synced reactive values across boundaries.
box.from
Creates a box from an existing box, a getter function, or a static value.
Useful for receiving arguments that may or may not be reactive.
box.flatten
Transforms any boxes within an object to reactive properties, removing the need to access each
property with .value.
box.readonly
Creates a readonly box from a writable box that remains in sync with the original box.