Rust cross-platform reactive UI framework.
enum Event {
Increment,
Decrement,
}
fn counter(count: &i32) -> impl View<Web<Event>> {
(
Html::h1((), count.to_string()),
Html::button(on("click", |_| Event::Increment), "More"),
Html::button(on("click", |_| Event::Decrement), "Less"),
)
}
fn main() {
concoct::web::run(
0,
|count, event| match event {
Event::Increment => *count += 1,
Event::Decrement => *count -= 1,
},
counter,
);
}
Features
- Cross-platform components
- Compile-time UI tree
- Efficient view updates
- Inspired by the elm architecture
Getting started
Web
Install trunk or wasm-pack (this tutorial will show serving with trunk).
cargo add concoct --features web
Create an index.html file in the crate root
<html>
<body></body>
</html>
Create a main view and run it with Concoct
fn app(_state: &()) -> impl View<Web<()>> {
Html::h1((), "Hello World!"),
}
fn main() {
concoct::web::run(
0,
|_state, _event| {},
app,
);
}
All done! Check it out at http://localhost:8080
trunk serve