preload lazy routes without creating data twice

This commit is contained in:
Greg Johnston
2025-07-17 08:09:05 -04:00
parent 81b37a3867
commit f8fa6de987
2 changed files with 48 additions and 21 deletions

View File

@@ -32,7 +32,7 @@ where
}
async fn preload(&self) {
T::data().view().await;
T::preload().await;
}
}
@@ -40,6 +40,10 @@ pub trait LazyRoute: Send + 'static {
fn data() -> Self;
fn view(self) -> impl Future<Output = AnyView>;
fn preload() -> impl Future<Output = ()> {
async {}
}
}
#[derive(Debug)]