Show HN: Fusor – Like Vue, but the logic is Rust
10 hours ago
- The fusor framework combines component and page files where Rust code and HTML templates are integrated using four key interfaces: rust:component for state definition, bindings for dynamic value display and updates based on signal changes, on:click/bind for event handling and input-to-signal synchronization, and the template! macro to connect modules with their HTML for compiler verification.
- Running 'fusor new' creates the initial project structure including Cargo.toml, build.rs, and src/lib.rs; additional component modules must be declared in src/lib.rs.
- HTML templates are written as standard markup with CSS, and Rust code is inserted via double-brace expressions or special attributes like on:click.
- Application state is represented by a Rust struct with methods as its behavior; the compiler checks all template expressions against this struct for consistency.
- Rust code is compiled to WebAssembly for browser execution, with bindings that track signal dependencies and only re-render when relevant signals change, optimizing performance.
- Listeners, effects, and requests are scoped to their originating component and are automatically cleaned up when the component is removed; the <Async> element allows retaining the previous view until new data is ready.