Kagura
Frontend frame-work for wasm on Rust.
Tutorial
In English
In Japanese
[Kagura] Kagura + Rust でWebページを作成
Hello World
extern crate kagura;
extern crate wasm_bindgen;
use *;
use *;
;
;
;
Usage
Create component
new
update
and render
is function :
update : fn
render : fn
Set a component to application
run
Render Element
html_tag
attributes
: instance of kagura::Attributes
events
: instance of kagura::Events
children
: Vec<Html>
Example
foo
bar
baz
is made by
use Html;
use Attributes;
use Events;
ul
Render Component
component
component
: instance of kagura::Component
Transmit message to a parent component
update
can send message to parent compoent as Some(message).
Receive child message and bind to own message
component.subscribe(impl: Sub -> Box<Any>)
can receive message from child component and bind to own message.
Example
Cmd
Cmd::none()
Cmd::none()
means nothing to do. If you return Cmd::none(), kagura will render.
Cmd::sub(sub: Sub)
If you send sub-message to parent component, use this.
Cmd::task(|resolve| some_task)
This works like promise in JavaScript. When you give msg to resolve, resolve dispatch msg to update and rerender. It will be useful for setTimeout, some heavy task, and so on.