6 releases
new 0.3.0-alpha.3 | May 10, 2024 |
---|---|
0.3.0-alpha.2 | May 7, 2024 |
0.3.0-alpha.1 | May 5, 2024 |
0.2.0 | Feb 24, 2024 |
0.1.0 | Feb 23, 2024 |
#8 in #virtual-dom
245 downloads per month
21KB
555 lines
A high-performance reactive user-interface framework for Rust. This crate provides a generic library that lets you define UI using declarative, type-safe syntax. Views combine together to form a statically-typed view tree that can be stored on the stack, giving this architecture its high performance.
use actuate::{use_state, Scope, View, VirtualDom};
struct Counter {
start: i32,
}
impl View for Counter {
fn body(&self, cx: &Scope) -> impl View {
let (count, set_count) = use_state(cx, || self.start);
set_count.set(count + 1);
dbg!(count);
}
}
struct App;
impl View for App {
fn body(&self, _cx: &Scope) -> impl View {
(Counter { start: 0 }, Counter { start: 100 })
}
}
#[tokio::main]
async fn main() {
let mut vdom = VirtualDom::new(App.into_node());
tokio::spawn(async move {
vdom.run().await;
vdom.run().await;
})
.await
.unwrap();
}
Inspiration
This crate is inspired by Xilem and uses a similar approach to type-safe reactivity. The main difference with this crate is the concept of scopes, components store their state in their own scope and updates to that scope re-render the component.
State management is inspired by React and Dioxus, but this project aims to be higher performance by taking advantage of multi-threading.
Dependencies
~2.6–8.5MB
~62K SLoC