Function zng_wgt::node::with_context_var_init

source ·
pub fn with_context_var_init<T: VarValue>(
    child: impl UiNode,
    var: ContextVar<T>,
    init_value: impl FnMut() -> BoxedVar<T> + Send + 'static
) -> impl UiNode
Expand description

Helper for declaring properties that sets a context var to a value generated on init.

The method calls the init_value closure on init to produce a value var that is presented as the ContextVar<T> in the widget and widget descendants. The closure can be called more than once if the returned node is reinited.

Apart from the value initialization this behaves just like with_context_var.