finished moving out render_state
This commit is contained in:
@@ -11,11 +11,15 @@ struct State {
|
||||
}
|
||||
|
||||
impl DefaultAppState for State {
|
||||
fn new(ui_state: DefaultUiState, rsc: &mut DefaultRsc<Self>, _: Proxy<Self::Event>) -> Self {
|
||||
fn new(
|
||||
mut ui_state: DefaultUiState,
|
||||
rsc: &mut DefaultRsc<Self>,
|
||||
_: Proxy<Self::Event>,
|
||||
) -> Self {
|
||||
let rect = rect(Color::RED).add(rsc);
|
||||
rect.task_on(CursorSense::click(), async move |mut ctx| {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
ctx.task.update(move |_, rsc| {
|
||||
ctx.update(move |_, rsc| {
|
||||
let rect = rect(rsc);
|
||||
if rect.color == Color::RED {
|
||||
rect.color = Color::BLUE;
|
||||
@@ -24,7 +28,7 @@ impl DefaultAppState for State {
|
||||
}
|
||||
});
|
||||
})
|
||||
.set_root(rsc);
|
||||
.set_root(rsc, &mut ui_state);
|
||||
Self { ui_state }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user