use crate::{MainApp, MainMsg}; use simi::prelude::*; pub struct Context { parent: WeakMain, } impl AppContext for Context { fn init(_main: WeakMain, parent: WeakMain) -> Self { Self { parent } } } pub enum Msg { SetDelta(i32), ButtonClick, } pub struct SubApp { delta: i32, } impl Application for SubApp { type Message = Msg; type Context = Context; type Parent = WeakMain; fn init() -> Self { SubApp { delta: 1 } } fn update(&mut self, m: Self::Message, cp: ContextPlus) -> UpdateView { match m { Msg::SetDelta(value) => self.delta = value, Msg::ButtonClick => cp.context.parent.send_message(MainMsg::Delta(self.delta)), } false } fn render(&self, context: RenderContext) { application! { button (onclick=Msg::ButtonClick) { "Click me" } } } }