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

Restore signal lifetimes; rename take to manually drop #2022

Merged
merged 4 commits into from
Mar 8, 2024

Conversation

ealmloff
Copy link
Member

@ealmloff ealmloff commented Mar 8, 2024

This PR renames the take method on signals to manually_drop to make it easier to find and restore local lifetime tracking for signals.

Note while local lifetime tracking can help prevent some bugs at compile time, it can make some common situations less ergonomic including matching the value of a resource:

// fut.read() now causes an error
match fut.read_unchecked().as_ref() {
    Some(Ok(resp)) => rsx! {
        button { onclick: move |_| fut.restart(), "Click to fetch another doggo" }
        div { img { max_width: "500px", max_height: "500px", src: "{resp.message}" } }
    },
    Some(Err(_)) => rsx! { div { "loading dogs failed" } },
    None => rsx! { div { "loading dogs..." } },
}

Closes #2011
Closes #2009

@ealmloff ealmloff added enhancement New feature or request breaking This is a breaking change signals Related to the signals crate labels Mar 8, 2024
@jkelleyrtp jkelleyrtp merged commit 4a27b16 into DioxusLabs:main Mar 8, 2024
8 of 9 checks passed
@ealmloff ealmloff deleted the signal-lifetimes branch March 8, 2024 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This is a breaking change enhancement New feature or request signals Related to the signals crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve signal lifetime tracking and make it easier to opt-out enhancement: Support manual drop of Signals
2 participants