Function zng_wgt::on_init

source ·
pub fn on_init(
    child: impl UiNode,
    handler: impl WidgetHandler<OnNodeOpArgs>,
) -> impl UiNode
Expand description

P Widget initialized.

This property calls handler when the widget and its content initializes. Note that widgets can be reinitialized, so the handler can be called more then once, you can use one of the once handlers to only be called once or use the arguments count. to determinate if you are in the first init.

Note that the widget is not in the WidgetInfoTree when this event happens, you can use on_info_init for initialization that depends on the widget info.

§Handlers

This property accepts any WidgetHandler, including the async handlers. Use one of the handler macros, hn!, hn_once!, async_hn! or async_hn_once!, to declare a handler closure.

§Async

The async handlers spawn a task that is associated with the widget, it will only update when the widget updates, so the task pauses when the widget is deinited, and is canceled when the widget is dropped.