dioxus/examples/webview.rs

28 lines
889 B
Rust
Raw Normal View History

2021-01-22 20:50:16 +00:00
//! Example: Webview Renderer
2021-01-26 19:02:35 +00:00
//! -------------------------
2021-01-22 20:50:16 +00:00
//!
//! This example shows how to use the dioxus_webview crate to build a basic desktop application.
//!
//! Under the hood, the dioxus_webview crate bridges a native Dioxus VirtualDom with a custom prebuit application running
//! in the webview runtime. Custom handlers are provided for the webview instance to consume patches and emit user events
//! into the native VDom instance.
2021-01-21 16:10:31 +00:00
use dioxus::prelude::*;
2021-03-04 23:12:24 +00:00
async fn main() {
dioxus_webview::launch(|ctx| {
2021-06-03 16:02:46 +00:00
let (count, set_count) = use_state(&ctx, || 0);
2021-01-22 20:50:16 +00:00
2021-03-04 23:12:24 +00:00
ctx.render(rsx! {
div {
h1 { "Dioxus Desktop Demo" }
p { "Count is {count}" }
button {
2021-01-22 20:50:16 +00:00
"Click to increment"
2021-03-04 23:12:24 +00:00
onclick: |_| set_count(count + 1)
}
}
})
}).await;
2021-01-21 16:10:31 +00:00
}