diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 39 | ||||
-rw-r--r-- | src/main.rs | 5 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..317c41d --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,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!() + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c6ac72a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,5 @@ +//! Main application starting point + +fn main() { + yew::start_app::<cookbook_render::Main>(); +} |