pub fn on_entity<V, O, F>(
entity: &Entity<V>,
f: F,
) -> OnUi<impl Fn(&mut App) -> Result<O, ActionError> + Send + Sync + 'static>Expand description
Build a parameterless action that mutates a gpui [Entity] on the main
thread, exactly like a button’s cx.listener.
The returned value is what ActionBuilder::on
accepts (it builds on on_ui(|cx|)).
ⓘ
win.actions().add("increment", "Increment").on(on_entity(&counter, |c, cx| {
c.bump(1, cx);
Ok::<_, ActionError>(Outcome::message(format!("count = {}", c.count)))
}));