Merge branch 'master' of github.com:DioxusLabs/dioxus

This commit is contained in:
Jonathan Kelley committed 2022-12-09 15:04:04 -08:00
commit dbf59f7c57
20 files changed
+535 -308

No files matched your search

+14 -1
View File
@@ -1,4 +1,5 @@
use dioxus::prelude::*;
use dioxus_desktop::EvalResult;
fn main() {
dioxus_desktop::launch(app);
@@ -7,6 +8,15 @@ fn main() {
fn app(cx: Scope) -> Element {
let script = use_state(cx, String::new);
let eval = dioxus_desktop::use_eval(cx);
let future: &UseRef<Option<EvalResult>> = use_ref(cx, || None);
if future.read().is_some() {
let future_clone = future.clone();
cx.spawn(async move {
if let Some(fut) = future_clone.with_mut(|o| o.take()) {
println!("{:?}", fut.await)
}
});
}
cx.render(rsx! {
div {
@@ -16,7 +26,10 @@ fn app(cx: Scope) -> Element {
oninput: move |e| script.set(e.value.clone()),
}
button {
onclick: move |_| eval(script.to_string()),
onclick: move |_| {
let fut = eval(script);
future.set(Some(fut));
},
"Execute"
}
}