Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

executable file 46 lines (34 sloc) 644 Bytes
use seed::{*, prelude::*};
// Model
struct Model {
pub val: i32,
}
impl Default for Model {
fn default() -> Self {
Self {
val: 0,
}
}
}
// Update
#[derive(Clone)]
enum Msg {
Increment,
}
fn update(msg: Msg, model: &mut Model, _: &mut impl Orders<Msg>) {
match msg {
Msg::Increment => model.val += 1,
}
}
// View
fn view(model: &Model) -> impl View<Msg> {
button![
simple_ev(Ev::Click, Msg::Increment),
format!("Hello, World × {}", model.val)
]
}
#[wasm_bindgen(start)]
pub fn render() {
App::builder(update, view)
.build_and_start();
}
You can’t perform that action at this time.