You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// ...fnuse_delayed_double(x:Signal<usize>) -> Signal<usize>{letmut foo = use_signal(|| x());use_memo(move || {let y = x *2;spawn(asyncmove{
log::debug!("Sleeping...");sleep(100).await;
log::debug!("Writing signal");*foo.write() = y;// <<---- Writing to the signal.});});
foo
}#[allow(non_snake_case)]fnApp() -> Element{letmut x = use_signal(|| 123);let double = use_delayed_double(x);use_effect(move || {let double = double();
log::debug!("double: {:?}", double);// <<---- Expecting the side effect to be executed.});rsx!{
button {
onclick: move |_| x += 1,
"increment"},
"x: {x}"// "double: {double}" // <<---- When commenting this line in, logging "double" works as expected.}}
Heyo,
thank you for this great library! I'm having a problem with signals that I reduced to a minimal example.
I want to run a side effect within a
use_effect
that is derived from a signal. The signal itself is not used for rendering.When writing to this signal asynchronously, I can not get it to fire consistently (it works sometimes, but very rarely).
Steps To Reproduce
Cargo.toml
main.rs
Expand to see full fileLaunch app using
dx serve
.output
Expected behavior
output
Environment:
dioxus 0.5.4
rustc 1.76.0 (07dca489a 2024-02-04)
macOS 14.2.1
web
Questionnaire
The text was updated successfully, but these errors were encountered: