Crates.io | actuate |
lib.rs | actuate |
version | 0.4.0-alpha.3 |
source | src |
created_at | 2024-02-23 23:51:59.140906 |
updated_at | 2024-11-10 08:40:33.389197 |
description | A reactive user-interface framework |
homepage | |
repository | https://github.com/actuate-rs/actuate |
max_upload_size | |
id | 1151083 |
size | 40,337 |
A high-performance reactive user-interface framework for Rust. This crate provides a generic library that lets you define UI using declarative, borrow-checker friendly syntax.
use actuate::{use_mut, Compose, Data, Memo, Mut, Scope};
#[derive(Hash, Data)]
struct Button<'a> {
count: Mut<'a, i32>,
}
impl Compose for Button<'_> {
fn compose(cx: Scope<Self>) -> impl Compose {
cx.me().count.update(|x| *x += 1)
}
}
#[derive(Data)]
struct Counter {
initial: i32,
}
impl Compose for Counter {
fn compose(cx: Scope<Self>) -> impl Compose {
let count = use_mut(&cx, || cx.me().initial);
dbg!(*count);
(Memo::new(Button { count }), Button { count })
}
}
#[tokio::main]
async fn main() {
actuate::run(Counter { initial: 0 }).await;
}
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.