Giter VIP home page Giter VIP logo

Comments (4)

TapGhoul avatar TapGhoul commented on September 22, 2024

Worth a note: this was encountered at first when doing loading screen stuff with server functions and use_server_future() - but this is a more minimal and targeted sample. The broken bit is unrelated to server fns.

from dioxus.

TapGhoul avatar TapGhoul commented on September 22, 2024

@jkelleyrtp it seems the bug is not fixed. Tested with git 821a650, same test code as above.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on September 22, 2024

Sorry for the delay - we've put in many fixes regarding async since April and I think this might already be fixed - but I'll let @ealmloff double check.

from dioxus.

ealmloff avatar ealmloff commented on September 22, 2024

This updated version of the example reproduction works:

// [dependencies]
// dioxus = { path = "/Users/evanalmloff/Desktop/Github/dioxus/packages/dioxus", features = ["web"] }
// dioxus-logger = "0.5.1"
// gloo-timers = { version = "0.3.0", features = ["futures"] }
// tracing = "0.1.40"

use std::time::Duration;

use dioxus::prelude::*;
use tracing::Level;

fn main() {
    dioxus_logger::init(Level::TRACE).unwrap();
    launch(Broken)
}

#[component]
fn Broken() -> Element {
    let signal = use_signal(|| false);
    let _future = use_resource(move || async move { signal() });
    let action = move |_| {
        spawn_forever(async move {
            let d = DropDetector;
            let mut signal = signal.clone();
            tracing::info!("Start of signal set");
            signal.set(true);
            tracing::info!("Set to true");
            gloo_timers::future::sleep(Duration::from_millis(500)).await;
            tracing::info!("Timer finished");
            signal.set(false);
            tracing::info!("Signal set to false");
            drop(d);
        });
    };

    rsx! {
        div {
            div { "State: {signal}" }
            button { onclick: action, "press me" }
        }
    }
}

struct DropDetector;
impl Drop for crate::DropDetector {
    fn drop(&mut self) {
        tracing::warn!("Dropped DropDetector!");
    }
}

from dioxus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.