Skip to main content

environment_reader

Function environment_reader 

Source
pub fn environment_reader<V: IntoView>(
    builder: impl Fn(EnvironmentValues) -> V + 'static,
) -> View
Expand description

A view whose content is a function of the environment.

What @Environment is for, without having to be a view type: the closure is handed the live EnvironmentValues and returns whatever it wants to build from them. Reading a key declared here is value_for, which is typed by the key.

environment_keys! { depth: i64 = 0 }

environment_reader(|env| text(&format!("{} deep", env.value_for(depth()))))