DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.05k stars 764 forks source link

Restore signal lifetimes; rename take to manually drop #2022

Closed ealmloff closed 5 months ago

ealmloff commented 5 months ago

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 https://github.com/DioxusLabs/dioxus/issues/2011 Closes https://github.com/DioxusLabs/dioxus/issues/2009