respo/lib.rs
1//! Tiny **virtual DOM** library, compiles to WebAssembly, runs in browser, building interactive web apps with declarative code.
2//!
3//! This library is experimental, heavily influenced by React.js and ClojureScript.
4//! Previously implementeded in [ClojureScript](https://github.com/Respo/respo.cljs) and [Calcit](https://github.com/Respo/respo.calcit).
5//!
6//! 
7//!
8//! To build UI:
9//!
10//! - there's Virtual DOM, although simplified, still flexible for declarative UI
11//! - CSS with Rust macros, I call it "CSS in Rust"
12//! - Effects, flow from data to DOM, for patching DOM manually on data change
13//! - `respo::ui` provides basic style. Also try Modal, dialog, drawer components.
14//!
15//! To manage states:
16//!
17//! - Rust enum and pattern matching it really nice for Elm-style action dispatching
18//! - global states tree and cursor to maintain states, may not be familiar but still being handy
19//! - you may also write shared component like a "plugin" to manage states.
20//!
21//! To optimize:
22//!
23//! - components and elements are in functions, available for [memoize](https://crates.io/crates/memoize)
24//! - well, it's Rust, you can do more...
25//!
26//! Meanwhile it does not support React features such as:
27//!
28//! - ❌ updating data from render. Respo enforces "unidirectional data flow". That's not allowed
29//! - ❌ hooks API and context. Respo uses plain functions without tricky internal states
30//! - ...does not have many other advanced features from React
31//!
32//! Rust and WebAssembly lacks tricks for hot reloading,
33//! it's suggested to use [trunk](https://github.com/trunk-rs/trunk) to edit and reload the project during development.
34//! App states including components states can be saved to local storage and reloaded.
35//!
36//! To start project, create your structs to implement traits:
37//!
38//! - `RespoStore` for global states and states tree, and `RespoAction` for updating
39//! - `RespoApp` for MVC overview of the app, and more views, bind events
40//!
41//! say app is called `app`, you start app with `app.render_loop()`.
42//! Check [Workflow](https://github.com/Respo/respo-rust-workflow/tree/c7cc0c0/src) for a working example.
43
44mod app;
45pub mod states_tree;
46
47pub(crate) mod node;
48pub mod ui;
49
50pub use node::element::alias::*;
51pub use node::*;
52
53pub use app::{util, RespoApp, RespoStore};