dioxus/examples/webview.rs

32 lines
962 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-06-24 15:09:38 +00:00
//!
//! Currently, NodeRefs won't work properly, but all other event functionality will.
2021-01-22 20:50:16 +00:00
2021-01-21 16:10:31 +00:00
use dioxus::prelude::*;
2021-06-17 22:00:32 +00:00
fn main() {
2021-07-08 13:29:12 +00:00
dioxus::desktop::launch(App, |c| c);
2021-06-24 15:09:38 +00:00
}
2021-01-22 20:50:16 +00:00
2021-06-24 15:09:38 +00:00
static App: FC<()> = |cx| {
2021-07-07 20:19:10 +00:00
let (count, set_count) = use_state_classic(cx, || 0);
2021-06-24 15:09:38 +00:00
cx.render(rsx! {
div {
h1 { "Dioxus Desktop Demo" }
p { "Count is {count}" }
button {
"Click to increment"
onclick: move |_| set_count(count + 1)
2021-03-04 23:12:24 +00:00
}
2021-06-24 15:09:38 +00:00
}
})
};