use crate::model::BCard; use wasm_bindgen::prelude::*; use yew::prelude::*; struct Form { link: ComponentLink, bcard: BCard, } impl Component for Form { // probably not necessary but who knows type Message = (); type Properties = (); fn create(_: Self::Properties, link: ComponentLink) -> Self { Self { link } } fn update(&mut self, _: Self::Message) -> ShouldRender { false } fn change(&mut self, _: Self::Properties) -> ShouldRender { false } fn view(&self) -> Html { html! { } } } // example struct Model { link: ComponentLink, value: i64, } enum Msg { AddOne, Input(BCard), } impl Component for Model { type Message = Msg; type Properties = (); fn create(_: Self::Properties, link: ComponentLink) -> Self { Self { link, value: 0, } } fn update(&mut self, msg: Self::Message) -> ShouldRender { match msg { Msg::AddOne => self.value += 1 } true } fn change(&mut self, _props: Self::Properties) -> ShouldRender { // Should only return "true" if new properties are different to // previously received properties. // This component has no properties so we will always return "false". false } fn view(&self) -> Html { html! {

{ self.value }

} } } #[wasm_bindgen(start)] pub fn run_app() { App::::new().mount_to_body(); }