pub fn with_environment<T: Clone + 'static>(
value: T,
content: impl FnOnce() -> AnyPiece + 'static,
) -> AnyPieceExpand description
Provide an ambient value T to content and its ENTIRE descendant subtree (the SwiftUI
@Environment/.environment(_) analog, layered over day-reactive’s scope context). content
— and any piece built within it — reads it back with environment. A thin, non-reactive
wrapper: T is a snapshot captured here; for a value that must react, provide a Signal<T>
(or a Memo<T>) and read it reactively inside the subtree.
ⓘ
#[derive(Clone)] struct Theme { accent: Color }
with_environment(Theme { accent: BLUE }, || my_screen())
// deep inside my_screen(): let accent = environment::<Theme>().unwrap().accent;