use iris::prelude::*; use std::time::Duration; fn main() { DesktopApp::::run(); } #[derive(DesktopUiState)] struct State { ui_state: DesktopUiState, } impl DesktopAppState for State { fn new( mut ui_state: DesktopUiState, rsc: &mut DesktopRsc, _: Proxy, ) -> Self { let rect = rect(PaintId::RED).add(rsc); rect.task_on(CursorSense::click(), async move |mut ctx| { tokio::time::sleep(Duration::from_secs(1)).await; ctx.update(move |_, rsc| { let rect = rect(rsc); if rect.is_paint(&PaintId::RED) { rect.set_paint(PaintId::BLUE); } else { rect.set_paint(PaintId::RED); } }); }) .set_root(rsc, &mut ui_state); Self { ui_state } } }