Crates.io | silkenweb-dom |
lib.rs | silkenweb-dom |
version | 0.1.3 |
source | src |
created_at | 2021-04-29 10:52:55.107131 |
updated_at | 2023-01-07 00:35:16.191388 |
description | Silkenweb DOM API |
homepage | https://github.com/silkenweb/silkenweb |
repository | https://github.com/silkenweb/silkenweb |
max_upload_size | |
id | 390984 |
size | 29,002 |
This is an old implementation crate for Silkenweb that is no longer used.
A library for building reactive single page web apps.
input().dom_element()
returns a web_sys::HtmlInputElement
button().on_click(...)
passes your event handler a web_sys::HtmlInputElement
and a web_sys::MouseEvent
.use silkenweb::{
elements::{button, div, p},
mount,
signal::Signal,
};
fn main() {
let count = Signal::new(0);
let set_count = count.write();
let inc = move |_, _| set_count.replace(|&i| i + 1);
let count_text = count.read().map(|i| format!("{}", i));
let app = div()
.child(button().on_click(inc).text("+"))
.child(p().text(count_text));
mount("app", app);
}
rustup target add wasm32-unknown-unknown
cargo install trunk wasm-pack
cargo install wasm-bindgen-cli --version 0.2.73
cd examples/counter
trunk serve --open