dioxus/examples/callback.rs

23 lines
454 B
Rust
Raw Normal View History

2022-11-19 21:21:02 +00:00
use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
2022-12-07 00:37:28 +00:00
let login = use_callback!(cx, move |_| async move {
2022-11-19 21:43:19 +00:00
let res = reqwest::get("https://dog.ceo/api/breeds/list/all")
.await
.unwrap()
.text()
.await
.unwrap();
2022-12-07 00:37:28 +00:00
println!("{:#?}, ", res);
2022-11-19 21:21:02 +00:00
});
cx.render(rsx! {
2022-11-19 21:43:19 +00:00
button { onclick: login, "Click me!" }
2022-11-19 21:21:02 +00:00
})
}