Skip to content

API Reference

ReactiveObjects.ReactiveObject Type
julia
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.

source
ReactiveObjects.fcopy! Method
julia
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.

source
ReactiveObjects.rcopy! Method
julia
rcopy!(dest, val)

Reactive copy: copy val into dest in-place, dispatching by type.

  • Arrays: copy!(dest, val)

  • Ref: dest[] = val

  • NamedTuple/Tuple: element-wise rcopy!

  • Function: no-op

  • ReactiveObject: copies both valid flags and data

source
ReactiveObjects.restore! Function
julia
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.

source
ReactiveObjects.@invalidatedependants! Macro
julia
@invalidatedependants! obj.field = value

Assign 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).

source
ReactiveObjects.@node Macro
julia
@node expr

Cache a subexpression as an intermediate tracked field inside a @reactive block. Only valid inside @reactive; errors if used standalone.

source
ReactiveObjects.@reactive Macro
julia
@reactive name(args...) = begin
    derived = f(args...)
    ...
end

Define 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:

julia
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).

source
You are viewing the dev branch. This branch may include code written with Claude Code with less human supervision. Only human-approved code is merged into main.