refactor: replace load method with reload, returning Command

This commit is contained in:
Michael Aaron Murphy 2024-01-16 17:04:55 +01:00 committed by Michael Murphy
parent c6bf1525d8
commit 3787bf8cbc
7 changed files with 25 additions and 38 deletions

View file

@ -14,7 +14,7 @@ pub use section::Section;
use derive_setters::Setters;
use slotmap::SlotMap;
use std::{borrow::Cow, future::Future, pin::Pin};
use std::borrow::Cow;
slotmap::new_key_type! {
/// The unique ID of a page.
@ -24,9 +24,6 @@ slotmap::new_key_type! {
/// A collection of sections which a page may be comprised of.
pub type Content = Vec<section::Entity>;
/// A request by a page to run a command in the background.
pub type Task<Message> = Pin<Box<dyn Future<Output = Message> + Send>>;
pub trait Page<Message: 'static>: Downcast {
/// Information about the page
fn info(&self) -> Info;
@ -51,8 +48,8 @@ pub trait Page<Message: 'static>: Downcast {
#[must_use]
#[allow(unused)]
fn load(&self, page: crate::Entity) -> Option<crate::Task<Message>> {
None
fn reload(&mut self, page: crate::Entity) -> Command<Message> {
Command::none()
}
/// Emit a command when the page is left