enum ViewInvalidation
Swift
enum ViewInvalidation
"Something changed; do at least this much work again."
The frame loop decides when to act on it, which is what keeps the
design frame-driven — a state change never synchronously walks the
graph. .body additionally tracks which composite nodes actually need
to run again (markBodyDirty), so a change three levels deep does not
force every unrelated node's body to recompute along with it — only
wherever .body was raised without naming a node (the first frame, or
state that lives outside the View-body-observation system entirely,
like a TextField's own buffer) falls back to rebuilding the whole tree,
which is always correct, just coarser than it has to be.
State lives per window on WindowScope; every method here resolves to one.
A coarse mark goes to the window whose frame is being processed, or to all
of them when that is nobody — see WindowScope for why those are the only
two answers that are ever right.
Sources/LavaUI/State.swift:263
Properties
static var isDirty: Bool { get }
Not documented.
Sources/LavaUI/State.swift:337
static var level: InvalidationLevel { get }
Not documented.
Sources/LavaUI/State.swift:338
Methods
static func consume() -> InvalidationLevel
Returns the work required for the current window, clearing its flag.
Sources/LavaUI/State.swift:317
static func consumeDirtyBodyNodes() -> [any BodyRecomputable]?
Drains the set of nodes to recompute individually. nil means the
caller should rebuild the whole tree from the root instead — either
nothing has been targeted yet (first frame) or .body was raised by
something that could not name the node responsible.
Sources/LavaUI/State.swift:327
static func markBodyDirty(_ node: some BodyRecomputable)
node's own tracked state changed. Unlike markDirty(), this does
not force every other composite node's body to run again this frame
— only node's, once consumeDirtyBodyNodes() processes it.
Routed by the node rather than by the ambient scope, because the write that triggered this can come from any window (or none).
Sources/LavaUI/State.swift:288
static func markDirty()
Called from withObservationTracking's onChange, i.e. before the
new value is written. Raising a level is safe there; reading state is not.
No node identity here, so this forces a full rebuild from the root —
prefer markBodyDirty(_:) wherever a specific node is in scope.
Sources/LavaUI/State.swift:269
static func markNeedsBody()
A view value changed: bodies must run again. Same "no specific node"
caveat as markDirty().
Sources/LavaUI/State.swift:273
static func markNeedsLayout()
Geometry changed but no view value did — a resize, a font swap.
Sources/LavaUI/State.swift:276
static func markNeedsRedraw()
Only pixels changed: an animation tick, a caret blink, a hover fill. The cheapest level, and the reason the cascade exists.
Sources/LavaUI/State.swift:280