2022-03-19 02:11:30 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
2024-01-16 17:45:02 +00:00
|
|
|
launch_desktop(app);
|
2022-03-19 02:11:30 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn app() -> Element {
|
2024-01-16 01:04:39 +00:00
|
|
|
let future = use_future(|| async move {
|
|
|
|
let mut eval = eval(
|
2023-10-23 20:26:10 +00:00
|
|
|
r#"
|
2023-07-21 22:36:25 +00:00
|
|
|
dioxus.send("Hi from JS!");
|
|
|
|
let msg = await dioxus.recv();
|
|
|
|
console.log(msg);
|
|
|
|
return "hello world";
|
|
|
|
"#,
|
2023-10-23 20:26:10 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
2023-07-21 22:36:25 +00:00
|
|
|
|
2023-10-23 20:26:10 +00:00
|
|
|
eval.send("Hi from Rust!".into()).unwrap();
|
|
|
|
let res = eval.recv().await.unwrap();
|
|
|
|
println!("{:?}", eval.await);
|
|
|
|
res
|
2023-07-21 22:36:25 +00:00
|
|
|
});
|
|
|
|
|
2024-01-16 01:04:39 +00:00
|
|
|
match future.value().read().as_ref() {
|
2024-01-16 19:18:46 +00:00
|
|
|
Some(v) => rsx!( p { "{v}" } ),
|
|
|
|
_ => rsx!( p { "waiting.." } ),
|
2023-07-21 22:36:25 +00:00
|
|
|
}
|
2022-03-19 02:11:30 +00:00
|
|
|
}
|