Closed tronta closed 3 years ago
Actually, we want to store as much state as possible in components. But in this case it's not necessary. So it has not directly something to do with simplicity. There's simply nothing that can be stored in the component.
Wouldn't it also be possible to store which button has been pressed last and the root component reads it from there?
Yes that would be possible, it's not as simple because of Rust's ownership rules. In this case you'd need to send a message to the component to ask for its state and wait for a response. Or you use Rc<RefCell
That would be great. I usually stumble over absolute sentences like 'there is no state' and I start thinking why is there no state... couldn't there be one...?! So a kind of reasoning would be great. In this case we could say we want only a stateless controlling component or such...
I'll have a look at this section when I'm back. You're right, there should be a bit more information why it's stateless.
This part should now have a better explanation: https://aaronerhardt.github.io/relm4-book/book/components.html#the-model
What about this? Maybe even, for good practice, we want to store the applications state centrally.