3 ms·
Commend on the attempt, foward thinking now wasm is getting more traction. but I can imagine that view syntax turning into an insane > circa the old days of cal
by bazza451 7y ago
Commend on the attempt, foward thinking now wasm is getting more traction. but I can imagine that view syntax turning into an insane > circa the old days of callbacks in nodejs
- ivanceras 7y agoAs long as all event callbacks are delegated into the update function and unified in an Msg enum, the code will have the same pattern regardless of how big the project is.
- bazza451 7y agoDidn’t mean callbacks, meant shape of the code with indents could get large and difficult to grep. JSX style macro over the top might help .
- ivanceras 7y agoIn that case, breaking up the functions into several smaller functions helps. The rule of thumb of the size of a function body shouldn't be larger than the size of a computer screen.
- mattigames 7y agoNot convinced that's the case, with a bit of code splitting the view may end looking more like (pseudo-code): fn view(&self) -> Node<Msg> { div(self.attributes(), self.content()) } fn content(&self) -> Node<Msg> { input([ class("client"), r#type("button"), value("Click me!"), onclick(|_| {sauron::log("Button is clicked"); Msg::Click}) ],[],) }
- ivanceras 7y agoYou can also take a look at the window_tab_rows example. It will allow you to modularize into isolated subcomponents which you can embed into the main component.