You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To make live easier I'm pasting original comments about the micro component way of working here:
I already mentioned "micro components". In this case two micro components would have to share state (using Rc<RefCell> which usually works fine). If micro components then had an update_view() method, you wouldn't even need to send a message but could just call that method.
For this a tracker that supports multiple views would also be interesting for efficient UI updates.
Anyway, to make my idea more tangible, I've written down some Rust-like code that represents the concept of "micro-components". Micro-components are "loose" so they need the parent to attach the root widget to its widgets. They don't need to store a clone of their parents sender but have a "data" field that holds (currently immutable) data that can be used to store senders and other stuff according to the needs of the user (to make them more flexible). They can easily be modified by their parent component and also handle messages. The view function can be called manually by using update_view(). Of course there are some possible panics but they should be easy to debug and the only other option to RefCell would be unsafe code.
What do you think? Would that make things easier for you? Is there a use-case that isn't properly covered?
structMicroComponent<Model:MicroModel>{model:Rc<RefCell<Model>>,widgets:Rc<RefCell<Model::Widgets>>,data:Mode::Data,// for additional data such as senders to other componentssender:Sender<Model::Msg>,}impl<Model:MicroModel>MicroComponent<Model>{fnnew(model:Model,data:Model::Data) -> Self{ ...}fnupdate_view(&self){ ...}fnmodel(&self) -> &Model{ ...}fnmodel_mut(&self) -> &mutModel{ ...}fnwidgets(&self) -> &Model::Widgets{ ...}fnsend(&self,msg:Model::Msg){ ...}fnsender(&self) -> Sender<Model::Msg>{ ...}}traitMicroModel{typeMsg;typeWidgets:MicroWidgets<Self>;typeData;fnupdate(&mutself,msg:Self::Msg,data:&Data,sender:Sender<Self::Msg>);}traitMicroWidgets<Model:MicroModel>{typeRoot;fninit_view(&mutself,model:&Model,sender:Sender<Mode::Msg>) -> Self;fnview(&mutself,model:&Model,sender:Sender<Mode::Msg>);fnroot_widget(&self) -> Self::Root;}
The text was updated successfully, but these errors were encountered:
For data store I've ended up writing my own variation about it. Without experiencing micro components I would not be able to do it again so either way they were useful.
@AaronErhardt I think all is ready in micro components. Can you review?
Let's take micro components discussion here.
To make live easier I'm pasting original comments about the micro component way of working here:
The text was updated successfully, but these errors were encountered: