Open
Description
Problem
Minimum test to understand how to use subsecond.
Works without tokio and async and does nothing (no error) when async is involved
Steps To Reproduce
Steps to reproduce the behavior:
- run dx serve --hot-patch
- See the line "Hello" being print over and over again
- change the string to "Hello World!" in the get_response function
- See the hot patching log from the dx cli
- Nothing change the line is still just "Hello"
Code :
// Import the dioxus_devtools crate for hot-reload and devtools integration.
use dioxus_devtools::connect_subsecond;
// Entry point of the application.
#[tokio::main]
async fn main() {
// Initialize the dioxus_devtools for hot-reloading.
connect_subsecond();
// Start the main application loop.
run_application().await;
}
// Main application loop that runs indefinitely.
async fn run_application() {
loop {
// Call the get_response function through subsecond::call to enable hot-reloading.
let greeting = subsecond::call(get_response).await;
// Print the result to the console.
println!("{greeting}");
// Sleep for 10 seconds before repeating.
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
}
}
// Function that returns a greeting string.
// This function can be hot-reloaded at runtime.
async fn get_response() -> String {
"Hello World!".to_string()
}
[dependencies]
dioxus-devtools = "0.7.0-alpha.1"
subsecond = "0.7.0-alpha.1"
tokio = { version = "1.45.1", features = ["full"] }
Same code without tokio and async works
Expected behavior
- run dx serve --hot-patch
- See the line "Hello" being print over and over again
- change the string to "Hello World!" in the get response method
- See the hot patching log from the dx cli
- The line now prints "Hello World!"
Screenshots
Environment:
- Dioxus version: dioxus 0.7.0-alpha.1 (662cf0d)
- Rust version: 1.87.0
- OS info: Windows 11
- App platform: None, just trying out subsecond
Questionnaire
I'm interested in fixing this myself but don't know where to start.