mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-18 07:11:04 +02:00
refactor: recv_glib
dependency arrays
Adds a dependency array system to `recv_glib` which internally clones the passed deps and then passes by reference to the callback. This cleans up a lot of the big `{}` blocks full of `widget.clone()` and removes a lot of boilerplate. Yay!
This commit is contained in:
parent
beab26a37e
commit
9d18ce52f5
31 changed files with 539 additions and 517 deletions
|
@ -56,8 +56,7 @@ impl Module<Label> for LabelModule {
|
|||
context: &WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
|
||||
_rx: mpsc::Receiver<Self::ReceiveMessage>,
|
||||
) -> Result<()> {
|
||||
let tx = context.tx.clone();
|
||||
dynamic_string(&self.label, move |string| {
|
||||
dynamic_string(&self.label, &context.tx, move |tx, string| {
|
||||
tx.send_update_spawn(string);
|
||||
});
|
||||
|
||||
|
@ -79,12 +78,9 @@ impl Module<Label> for LabelModule {
|
|||
label.truncate(truncate);
|
||||
}
|
||||
|
||||
{
|
||||
let label = label.clone();
|
||||
context
|
||||
.subscribe()
|
||||
.recv_glib(move |string| label.set_label_escaped(&string));
|
||||
}
|
||||
context.subscribe().recv_glib(&label, move |label, string| {
|
||||
label.set_label_escaped(&string)
|
||||
});
|
||||
|
||||
Ok(ModuleParts {
|
||||
widget: label,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue