Replies: 2 comments 2 replies
-
Let's see... looking at this naively, with no idea how I'd expect the naive |
Beta Was this translation helpful? Give feedback.
-
I did try some something similar to this using //Received WebSocket message
AppMessage::ValUpdate { table_id, val } => {
let initial_value = with! { |tables| {
tables.iter().find(|t| t.id == table_id).map(|t| t.val)
}};
if let Some(initial_value) = initial_value {
let tweener = Rc::new(RefCell::new(tween::Tweener::sine_in_out(
initial_value,
val,
0.5,
)));
let Pausable { pause, .. } = use_raf_fn(move |v| {
let v = tweener.borrow_mut().move_by(v.delta);
tables.update(|tables| {
tables
.iter_mut()
.find(|t| t.id == table_id)
.tap_some_mut(|t| t.val = v);
});
});
let UseTimeoutFnReturn { start, .. } = use_timeout_fn(
move |_: ()| {
pause();
},
500.0,
);
start(());
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi guys!
I have a button that, when clicked, runs a piece of code that updates a signal in a loop using the value provided by a tween library.
The code also logs the updated value to the console.
The problem is that while the values are successfully printed in the console, the value on the button does not get updated until the end of the loop.
I am having trouble understanding some aspect of reactivity and I have been searching the documentation, but to no avail.
I am trying to animate components, but I need to solve this issue first.
Can anyone help me out?
Beta Was this translation helpful? Give feedback.
All reactions