Added a run macro with useEffect like properties #30
This commit is contained in:
+5
-8
@@ -11,21 +11,18 @@ fn main() -> std::io::Result<()> {
|
||||
pub fn app() -> Rsx {
|
||||
let items: State<Vec<i32>> = use_state(vec![1, 2]);
|
||||
|
||||
std::thread::spawn({
|
||||
let items = items.clone();
|
||||
move || {
|
||||
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||
run! {
|
||||
use items
|
||||
{
|
||||
std::thread::sleep(std::time::Duration::from_millis(300));
|
||||
items.get().push(3);
|
||||
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||
items.get().remove(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
rsx! {
|
||||
FlexRow {
|
||||
for item in items {
|
||||
static "{item}"
|
||||
static "Idk {item}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user