Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: spawn_forever tasks get attached to the scope #2215

Closed
marc2332 opened this issue Apr 1, 2024 · 0 comments · Fixed by #2216
Closed

bug: spawn_forever tasks get attached to the scope #2215

marc2332 opened this issue Apr 1, 2024 · 0 comments · Fixed by #2216
Assignees

Comments

@marc2332
Copy link
Contributor

marc2332 commented Apr 1, 2024

Problem
spawn_forever tasks get attached to the scope

The task will never get executed because it's attached to the Scope, and the Scope is being dropped.

#[allow(non_snake_case)]
fn Counter() -> Element {
    use_drop(move || {
        println!("spawning");
        spawn_forever(async move {
            println!("running");
        });
    });

    None
}

fn app() -> Element {
    let mut count = use_signal(|| 0);

    rsx!(
        Button {
            onclick: move |_| count += 1,
            label { "Increase" }
        }
        Button {
            onclick: move |_| count -= 1,
            label { "Decrease" }
        }
        for i in 0..count() {
            Counter {
                key: "{i}"
            }
        }
    )
}

Expected behavior

Work

Environment:

  • Dioxus version: 0.5
  • Rust version: 1.77
  • OS info: Windows
  • App platform: Freya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants