mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
29 lines
681 B
Rust
29 lines
681 B
Rust
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app() -> Element {
|
|
let future = use_future(|| async move {
|
|
let mut eval = eval(
|
|
r#"
|
|
dioxus.send("Hi from JS!");
|
|
let msg = await dioxus.recv();
|
|
console.log(msg);
|
|
return "hello world";
|
|
"#,
|
|
)
|
|
.unwrap();
|
|
|
|
eval.send("Hi from Rust!".into()).unwrap();
|
|
let res = eval.recv().await.unwrap();
|
|
println!("{:?}", eval.await);
|
|
res
|
|
});
|
|
|
|
match future.value().read().as_ref() {
|
|
Some(v) => rsx!( p { "{v}" } ),
|
|
_ => rsx!( p { "waiting.." } ),
|
|
}
|
|
}
|