zng::widget

Function on_deinit

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

P Widget deinited.

This property calls handler when the widget deinits, after the widget content deinits. 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 deinit.

§Handlers

This property accepts the WidgetHandler that are not async. Use one of the handler macros, hn! or hn_once!, to declare a handler closure.

Note that async handlers do not work here because widget bound async tasks only advance past the first .await during widget updates, but the widget is deinited before that. You can use UPDATES.run or task::spawn to start an async task on deinit.

§Preview

You can use the on_pre_deinit event to receive this event before the widget content deinits.