State management

This commit is contained in:
2025-07-27 19:53:45 +02:00
parent 327f14d9ed
commit cba301db74
2 changed files with 67 additions and 65 deletions
+8 -6
View File
@@ -4,6 +4,14 @@ fn main() -> std::io::Result<()> {
let screen = Screen::new();
let count = use_state(0);
std::thread::spawn({
let count = count.clone();
move || loop {
std::thread::sleep(std::time::Duration::from_millis(1000));
**count.get() += 500;
}
});
screen
.draw(
Dependency::new({
@@ -14,11 +22,5 @@ fn main() -> std::io::Result<()> {
)
.component(Transform::center());
std::thread::spawn(move || loop {
std::thread::sleep(std::time::Duration::from_millis(900));
let c = (*count).clone();
count.set(c + 1);
});
screen.run()
}