remove typed stuff / just specify rsc if needed

This commit is contained in:
2026-01-03 18:06:05 -05:00
parent 59901b6580
commit f2ac6f195f
14 changed files with 126 additions and 164 deletions

View File

@@ -2,7 +2,8 @@ use cosmic_text::Family;
use std::{cell::RefCell, rc::Rc};
use winit::event::WindowEvent;
iris::state_prelude!(DefaultRsc<Client>);
use iris::prelude::*;
type ClientRsc = DefaultRsc<Client>;
fn main() {
DefaultApp::<Client>::run();
@@ -119,6 +120,7 @@ impl DefaultAppState for Client {
texts(rsc).push(msg_box);
})
.add(rsc);
let text_edit_scroll = (
msg_area.height(rest(1)),
(
@@ -126,8 +128,8 @@ impl DefaultAppState for Client {
(
add_text.width(rest(1)),
Rect::new(Color::GREEN)
.on(CursorSense::click(), move |ctx, rsc| {
rsc.run_event::<Submit>(add_text, &mut (), ctx.state);
.on(CursorSense::click(), move |ctx, rsc: &mut ClientRsc| {
rsc.run_event::<Submit>(add_text, (), ctx.state);
})
.sized((40, 40)),
)

View File

@@ -1,7 +1,6 @@
use iris::prelude::*;
use std::time::Duration;
iris::state_prelude!(DefaultRsc<State>);
fn main() {
DefaultApp::<State>::run();
}
@@ -14,17 +13,15 @@ struct State {
impl DefaultAppState for State {
fn new(ui_state: DefaultUiState, rsc: &mut DefaultRsc<Self>, _: Proxy<Self::Event>) -> Self {
let rect = rect(Color::RED).add(rsc);
rect.on(CursorSense::click(), move |_, rsc| {
rsc.tasks.spawn(async move |ctx| {
tokio::time::sleep(Duration::from_secs(1)).await;
ctx.update(move |_, rsc| {
let rect = rect(rsc);
if rect.color == Color::RED {
rect.color = Color::GREEN;
} else {
rect.color = Color::RED;
}
});
rect.task_on(CursorSense::click(), async move |mut ctx| {
tokio::time::sleep(Duration::from_secs(1)).await;
ctx.task.update(move |_, rsc| {
let rect = rect(rsc);
if rect.color == Color::RED {
rect.color = Color::GREEN;
} else {
rect.color = Color::RED;
}
});
})
.set_root(rsc);