aboutsummaryrefslogtreecommitdiff
path: root/cookbook-render/src/lib.rs
blob: 317c41dea2d4ca951ffb264cf483b2b96319f826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#![recursion_limit = "256"]

use yew::{Component, ComponentLink, Html, ShouldRender};

pub struct Main {
    link: ComponentLink<Self>,
    value: i64,
}

pub enum Msg {
    Incr,
    Decr,
}

impl Component for Main {
    type Message = Msg;
    type Properties = ();

    fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
        Self { link, value: 0 }
    }

    fn update(&mut self, msg: Self::Message) -> ShouldRender {
        match msg {
            Msg::Incr => self.value += 1,
            Msg::Decr => self.value -= 1,
        }

        true
    }

    fn change(&mut self, _: Self::Properties) -> ShouldRender {
        false
    }

    fn view(&self) -> Html {
        todo!()
    }
}