concoct 0.7.0

Cross-platform UI framework
Documentation

Rust cross-platform reactive UI framework.

enum Event {
    Increment,
    Decrement,
}

fn counter(count: &i32) -> impl View<Web<Event>> {
    (
        Html::h1().view(count.to_string()),
        view::once(
            Html::button()
                .on("click", |_| Event::Increment)
                .view("More"),
        ),
        view::once(
            Html::button()
                .on("click", |_| Event::Decrement)
                .view("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 and xilem architectures

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,
    );
}
trunk serve

All done! Check it out at http://localhost:8080