#gui-framework #gtk #framework #wasm #gxi-rs

gxi

Zero-Cost Cross-Platform Native Widget based Component System in Rust

12 releases (4 breaking)

0.6.1 Dec 29, 2021
0.6.0 Dec 23, 2021
0.4.0 Oct 26, 2021
0.3.0-alpha.2 Jun 29, 2021
0.1.3 Apr 29, 2021

#368 in GUI

MIT license

180KB
927 lines

GXI

Tests

Cross-Platform Native Widget based Component System in Rust

Using proc-macros, the gxi transpiler transpile a component tree into a stateful self-managed n-binary tree using observable sync/async state pattern, for maximum efficiency and lowest possible overhead, with close to no runtime cost. Inherently, eliminating the use of a virtual dom or a diffing algorithm. The component system is platform-agnostic, which allows the system to produce platform-dependent and independent components, merging them for code reuse and maintainability.

Platforms

  • Web wasm32-unknown-unknown
  • Desktop (GTK) Windows, Mac and Linux
  • Platform Independent (Web and GTK)
  • Android
  • Ios

Examples

use gxi::{gxi, set_state, State, StrongNodeType, Text};

pub fn cat_fact() -> StrongNodeType {
    let cat_fact = State::new(String::new());

    let fetch_cat_fact = set_state!(
        async || {
            let resp = reqwest::get("https://catfact.ninja/fact?max_length=140")
                .await
                .unwrap();
            *(*cat_fact).borrow_mut() = resp.text().await.unwrap();
        },
        [cat_fact]
    );

    // pre fetch cat memes
    fetch_cat_fact();

    return gxi! {
        div [
            button ( on_click = move |_| fetch_cat_fact() ) [
                Text ( value = "fetch cat memes!" )
            ],
            p [
                Text ( value = &cat_fact[..])
            ],
        ]
    };
}

Full src here

Code of conduct

Code of conduct can be found at CODE_OF_CONDUCT.md

Contributing

Make sure to read Contribution Guidelines before contributing.

Copyright (C) 2021 Aniket Prajapati

Licensed under the MIT LICENSE

Contributors

Dependencies

~1–3.5MB
~71K SLoC