Crate review

Crate review 

Source
Expand description

§reView - API Documentation

reView is a Rust library for creating front-end web apps using WebAssembly

  • Features a fluent API for declaring interactive HTML with Rust expressions.
  • Use a VirtualDOM to minimize DOM API calls for each page render.

reView is not production-ready, and it’s a WIP project so expect breaking changes between versions.

§Supported Targets (Client-Side Rendering)

  • wasm32-unknown-unknown

§Example

use review::EventType::OnClick;
use review::Tag::{Button, Div};
use review::{callback, children, component, use_state, ElementBuilder, VNode};

#[component(App)]
pub fn app() -> VNode {
    let (state, set_state) = use_state(0);

    Div.with_children(children!(
        format!("Current value {}", state),
        Button
            .with_child("Increase counter")
            .with_event(OnClick, callback!(move || { set_state(*state + 1) }))
    ))
    .into()
}

fn main() {
    review::init_logger(review::log::Level::Debug);

    review::render(App(()).into(), "root");
}

Re-exports§

pub use log;

Macros§

callback
This macro is used to declare event for a Tag element using the ElementBuilder API
children
This macro helps to declare children for a Tag element using the ElementBuilder API

Structs§

VElement
A VElement is a particulat type of VNode generated from a Tag

Enums§

EventType
Rappresent all possible js events used in reView
Tag
Rappresent all possible tag used in reView
VNode
A VNode rappresent a node in the VirtualDOM tree.

Traits§

ElementBuilder
This is the API to declare VNode in reView

Functions§

init_logger
Initialize the logger with the specified minimum log log::Level
render
Starts a reView app mounted to the element with the specified id.
use_effect
The Effect Hook lets you perform side effects in components
use_state
This hook is used to manage the state in a component.

Type Aliases§

State
The type returned from a use_state hook

Attribute Macros§

component
This attribute creates a component from a normal Rust function.
hook
This attribute creates a user-defined hook from a normal Rust function.