with_context_var_init

Function with_context_var_init 

Source
pub fn with_context_var_init<T>(
    child: impl IntoUiNode,
    var: ContextVar<T>,
    init_value: impl FnMut() -> Var<T> + Send + 'static,
) -> UiNode
where T: VarValue,
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.