e::div()
.add_child_if(condition, move || e::div().text("this only sometimes"))
rather than
element.add_on_click(move |_| {
run_some_fn_taking_ownership(owned_string.clone(), some_struct.clone());
});
do this
element.add_on_click_once(move |_| {
run_some_fn_taking_ownership(owned_string, some_struct);
});
Should be possible by using Closure::once_into_js
and also having special handlers that are also dropped as soon as the fn is called. Useful for stuff like buttons that do work and delete element, buttons that navigate to different pages, etc.