There are many other features available in relm and I wanted to show you the most important of them: the syntax that is provided to simulate property binding. As you may have noticed by now, there's no property in relm
widgets, but you can use message passing to update the internal state of a relm
widget. To make it more convenient, the #[widget]
attribute also allows you to bind a model attribute to a message, this means that whenever the attribute is updated, the message will be emitted with this new value.
We'll add a toggle button to be able to switch between a simple and a detailed view for the playlist. The simple view will only show the cover and the title while the detailed view will show all the columns. First, let's add an attribute to the App
model:
pub struct Model { detailed_view: bool, // … } fn model() -> Model { Model { detailed_view: false, // … } }
This field specifies whether we're in the...