Component initialisation #79
-
Component init method doesn’t seems to be triggered…Is this a bug or should we need to call manually..If so where would be the best place to call manually? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@hchockarprasad, You have to manually call your Component's From the App's init function fn init(&mut self) -> Cmd<Self, Msg> {
Cmd::batch([
Cmd::new(|program| {
program.add_window_event_listeners(vec![
on_mousemove(|me| Msg::WebEditorMsg(web_editor::Msg::Mousemove(me))),
on_mousedown(|me| Msg::WebEditorMsg(web_editor::Msg::Mousedown(me))),
on_mouseup(|me| Msg::WebEditorMsg(web_editor::Msg::Mouseup(me))),
])
}),
Cmd::from(self.web_editor.init().localize(Msg::WebEditorMsg)),
])
} It calls into the In summary, Application is the only interface where the |
Beta Was this translation helpful? Give feedback.
@hchockarprasad, You have to manually call your Component's
init
function from your Application. Just likeupdate
in Component is also wired through your Application'supdate
function. I haven't included a simplified example for this use-case, since I'm still stabilizing the method signatures of thisinit
function in the Application and in the Component. However, A more advance usage is demonstrated here in the ultron editor, which I also wrote.From the App's init function