Store
Functions
new
Store.new<T>(initialState: T): TWraps a plain table in a deep reactive proxy: reading a field inside a computed or effect subscribes to that field, and assigning a new value re-runs only the dependents of the leaves that changed. Nested plain tables are proxied recursively on access; metatable'd values (Flux nodes, class instances) stay atomic. Available as Flux.store.
destroy
Store.destroy<T>(proxy: T)Tears down a store and every nested proxy beneath it, destroying their backing nodes so dependents stop tracking. Call this when a store created outside a scope is no longer needed; the raw table is left intact and can still be read directly.
unwrap
Store.unwrap<T>(proxy: T): TReturns the raw, un-proxied table underlying a store: the live backing object, not a copy. Reads through it bypass tracking entirely (no node is subscribed), so use it for cheap snapshots or to hand a plain table to non-reactive code. Passing a value that is not a store returns it unchanged.
insert
Store.insert(proxy: any, posOrValue: any, value: any?)Reactive counterpart of table.insert: inserts value at pos (default: appended to the end), shifting subsequent elements up. Use this instead of assigning past the array's length so iteration and # watchers fire and the shifted indices re-sync. An out-of-range pos errors.
Parameters
posOrValue: With no third argument, the value to append; otherwise the 1-based position to insert at.value: The value to insert when a position was given.
remove
Store.remove(proxy: any, pos: number?): anyReactive counterpart of table.remove: removes and returns the element at pos (default: the last), shifting subsequent elements down. Use this instead of proxy[i] = nil, which leaves a hole that corrupts the array part. An out-of-range pos errors.
move
Store.move(proxy: any, from: number, to: number)Reactively reorders the array, moving the element at from to to and shifting the elements between them so positional readers and #/iteration watchers follow. Equivalent to a table.remove + table.insert but as a single tracked step: the length is unchanged, so nothing is removed and no nested proxy is torn down, ideal for drag-and-drop list reordering. Both indices must be in [1, #proxy]; an out-of-range index errors.
Parameters
from: The 1-based index of the element to move.to: The 1-based index it should occupy afterward.
reconcile
Store.reconcile<T>(proxy: T, newData: T, key: string?): TDiffs the snapshot newData into the live store proxy, firing only the nodes whose leaves actually changed and reusing unchanged nested proxies instead of tearing them down. Arrays diff positionally by default; a key field name matches elements by identity instead, so reordered or inserted rows keep their proxy (and their For.value result) and only changed rows fire. newData should be a plain, acyclic snapshot. Returns proxy.
Parameters
key: Optional field name; when given, array elements are matched byelement[key]rather than by position, recursively through every nested array.