[][src]Crate yew

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

app

This module contains App sctruct which used to bootstrap a component in an isolated scope.

callback

This module contains structs to interact with Scopes.

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. Also this module contains declaration of Component trait which used to create own UI-components.

macros

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

prelude

The Yew Prelude

scheduler

This module contains a scheduler.

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

html
html_impl

Functions

initialize

Initializes yew framework. It should be called first.

run_loop

Starts event loop.