LavaUI docs

enum Environment

Swift

enum Environment

Scope stack for EnvironmentValues.

ViewGraph.mount/.reconcile recurse synchronously and depth-first — a composite's body is evaluated, and everything that construction produces (down to every default-argument read of Theme.current-alikes) happens nested inside that same call — so a plain stack sees the right frame at every nesting level: push before descending into an overridden subtree, pop right after ViewGraph.mount/.reconcile returns.

That stack is gone the next time a composite recomputes on its own. ViewInvalidation.markBodyDirty calls recomputeBody without walking back through the .font() / .theme() wrappers that originally pushed, so CompositeNode snapshots the stack at mount/parent-reconcile and replays it for those targeted passes. An empty snapshot still falls through to the live globals — a Theme.current toggle keeps reaching every subtree that never opted out.

Measure callbacks and the draw-list emit walk run later, as separate passes over the retained node tree with an empty stack — they read whatever a node captured from current at mount/reconcile time, not current itself.

Sources/LavaUI/Environment.swift:31

Properties

static var current: EnvironmentValues { get }

Falls through to the live globals wherever nothing pushed an override, so a Theme.current toggle keeps reaching every subtree that never opted out of the default.

Sources/LavaUI/Environment.swift:37