improv: create subscription channel for pages to send messages to

This commit is contained in:
Michael Aaron Murphy 2024-05-08 12:59:35 +02:00 committed by Michael Murphy
parent 11de7cbd4a
commit b443dd5b53
12 changed files with 104 additions and 26 deletions

View file

@ -11,4 +11,5 @@ libcosmic = { workspace = true }
generator = "0.7.5"
downcast-rs = "1.2.0"
once_cell = "1.19.0"
url = "2.5.0"
tokio.workspace = true
url = "2.5.0"

View file

@ -166,9 +166,13 @@ impl<Message: 'static> Binder<Message> {
}
/// Calls a page's load function to refresh its data.
pub fn page_reload(&mut self, id: crate::Entity) -> Command<Message> {
pub fn on_enter(
&mut self,
id: crate::Entity,
sender: tokio::sync::mpsc::Sender<Message>,
) -> Command<Message> {
if let Some(page) = self.page.get_mut(id) {
return page.reload(id);
return page.on_enter(id, sender);
}
Command::none()

View file

@ -59,9 +59,12 @@ pub trait Page<Message: 'static>: Downcast {
}
/// Reload page metadata via a Command.
#[must_use]
#[allow(unused)]
fn reload(&mut self, page: crate::Entity) -> Command<Message> {
fn on_enter(
&mut self,
page: crate::Entity,
sender: tokio::sync::mpsc::Sender<Message>,
) -> Command<Message> {
Command::none()
}