actuate

Crates.ioactuate
lib.rsactuate
version0.4.0-alpha.3
sourcesrc
created_at2024-02-23 23:51:59.140906
updated_at2024-11-10 08:40:33.389197
descriptionA reactive user-interface framework
homepage
repositoryhttps://github.com/actuate-rs/actuate
max_upload_size
id1151083
size40,337
Matt Hunzinger (matthunz)

documentation

README

Actuate

Crates.io version docs.rs docs CI status
Examples

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;
}

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.

Commit count: 122

cargo fmt