Crate yew [] [src]

Yew Framework - API Documentation

Yew is a framework for web-client apps created with a modern Rust-to-Wasm compilation feature. This framework was highly inspired by Elm and React.

Minimal example:

extern crate yew;
use yew::html::*;

struct Model {
    value: i64,
}

enum Msg {
    DoIt,
}

fn update(context: &mut Context<Msg>, model: &mut Model, msg: Msg) {
    match msg {
        Msg::DoIt => {
            model.value = model.value + 1;
        }
    }
}

fn view(model: &Model) -> Html<Msg> {
    html! {
        <div>
            <button onclick=|_| Msg::Increment,>{ "Add +1" }</button>
            <p>{ model.value }</p>
        </div>
    }
}

fn main() {
    let model = Model {
        value: 0,
    };
    program(model, update, view);
}

Modules

format

Utility module to convert data to types and back by specific formats like: JSON, BSON, TOML, YAML, XML.

html

The main module which contents aliases to necessary items to create a template and implement update and view functions.

macros

This module contains macros which implements html! macro and JSX-like templates.

services

This module is a container of servies to interact with the external resources.

virtual_dom

This module contains the implementation of reactive virtual dom concept.

Macros

debug
html
html_impl
warn

Functions

initialize

Initializes yew framework. It should be called first. No it actually initializes stdweb dependency only, but later it could contain own initialization code.

run_loop

Starts event loop.