pub struct LazyLoader<Args, Ret> { /* private fields */ }Expand description
A lazy loader that can be used to load a function from a split out .wasm file.
§Example
To use the split loader, you must first create the loader using the lazy_loader macro. This macro
requires the complete signature of the function you want to load. The extern abi string denotes
which module the function should be loaded from. If you don’t know which module to use, use auto
and wasm-split will automatically combine all the modules into one.
ⓘ
static LOADER: wasm_split::LazyLoader<Args, Ret> = wasm_split::lazy_loader!(extern "auto" fn SomeFunction(args: Args) -> Ret);
fn SomeFunction(args: Args) -> Ret {
// Implementation
}§The #[component(lazy)] macro
If you’re using wasm-split with Dioxus, the #[component(lazy)] macro is provided that wraps
the lazy loader with suspense. This means that the component will suspense until its body has
been loaded.
ⓘ
fn app() -> Element {
rsx! {
Suspense {
fallback: rsx! { "Loading..." },
LazyComponent { abc: 0 }
}
}
}
#[component(lazy)]
fn LazyComponent(abc: i32) -> Element {
rsx! {
div {
"This is a lazy component! {abc}"
}
}
}Implementations§
Auto Trait Implementations§
impl<Args, Ret> Freeze for LazyLoader<Args, Ret>
impl<Args, Ret> RefUnwindSafe for LazyLoader<Args, Ret>
impl<Args, Ret> Send for LazyLoader<Args, Ret>
impl<Args, Ret> Sync for LazyLoader<Args, Ret>
impl<Args, Ret> Unpin for LazyLoader<Args, Ret>
impl<Args, Ret> UnwindSafe for LazyLoader<Args, Ret>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more