API Reference
ReactiveObjects.ReactiveObject Type
ReactiveObject{S, D}A reactive object with lazy dependency-driven recomputation. S is the kernel signature symbol, D is the data NamedTuple. Field access triggers compute! for any invalid dependencies.
ReactiveObjects.fcopy! Method
fcopy!(dest, f, args...; kwargs...)Compute f(args...; kwargs...) and rcopy! the result into dest. Used internally by @reactive to update fields from their defining expressions.
ReactiveObjects.rcopy! Method
rcopy!(dest, val)Reactive copy: copy val into dest in-place, dispatching by type.
Arrays:
copy!(dest, val)Ref:dest[] = valNamedTuple/Tuple: element-wisercopy!Function: no-opReactiveObject: copies bothvalidflags anddata
ReactiveObjects.restore! Function
restore!(obj; force=true)Restore a ReactiveObject by recomputing fields. With force=true (default), all fields are invalidated first; with force=false, only already-invalid fields are recomputed.
ReactiveObjects.@invalidatedependants! Macro
@invalidatedependants! obj.field = valueAssign value to obj.field and invalidate all transitive dependants. Use this instead of plain obj.field = value when the assignment happens outside of setproperty! (e.g. in-place mutation of a sub-object's field).
ReactiveObjects.@node Macro
@node exprCache a subexpression as an intermediate tracked field inside a @reactive block. Only valid inside @reactive; errors if used standalone.
ReactiveObjects.@reactive Macro
@reactive name(args...) = begin
derived = f(args...)
...
endDefine a reactive kernel with automatic dependency tracking and lazy recomputation.
Each statement lhs = rhs in the body becomes a tracked property. When a property is set via obj.field = value, all transitive dependants are invalidated; when a property is read, it (and its dependencies) are recomputed on demand.
Tuple destructuring (a, b = f(x)) groups multiple fields under a single computation. @node(expr) extracts a sub-expression into its own cached intermediate field.
Methods can be defined inline:
scale(__self__, factor) = factor * y__self__ refers to the reactive object. Bare field names in method bodies are rewritten to __self__.field.
Definitions must be at module scope (the function name is used as a type parameter in ReactiveObject{S}, which requires a global binding).