macro_rules! AsyncFetch { (fetcher = $fetcher:block producer = |$bound_variable:pat_param| $producer:block) => {{ use leptos::{ prelude::{ElementChild, LocalResource, Suspend, Transition}, view, }; view! { "Loading..."

} }> {move || Suspend::new(async move { let resource = { LocalResource::new(move || $fetcher) }; resource .await .map(|$bound_variable| $producer) })}
} }}; } pub(crate) use AsyncFetch; // #[component] // pub fn AsyncFetch( // fetcher: impl Fn() -> Fut + 'static + Send + Sync, // producer: P, // ) -> impl IntoView // where // V: IntoView + 'static, // P: Fn(T) -> V + 'static + Send + Sync, // Fut: Future> + 'static, // T: 'static, // LocalResource>: IntoFuture> + Send, // { // view! { // "Loading..."

} // }> // { || Suspend::new(async { // let value_resource = LocalResource::new( || fetcher()); // value_resource // .await // .map(|value| { // producer(value) // }) // })} //
// } // }