Function zng::widget::node::with_context_var_init

source ยท
pub fn with_context_var_init<T>(
    child: impl UiNode,
    var: ContextVar<T>,
    init_value: impl FnMut() -> Box<dyn VarBoxed<T>> + Send + 'static,
) -> impl 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.