pub struct TransitionProps<Chil>{
pub fallback: ViewFnOnce,
pub set_pending: Option<SignalSetter<bool>>,
pub children: TypedChildren<Chil>,
}Expand description
Props for the Transition component.
If any Resource is read in the children of this
component, it will show the fallback while they are loading. Once all are resolved,
it will render the children.
Unlike Suspense, this will not fall
back to the fallback state if there are further changes after the initial load.
Note that the children will be rendered initially (in order to capture the fact that
those resources are read under the suspense), so you cannot assume that resources read
synchronously have
Some value in children. However, you can read resources asynchronously by using
Suspend.
async fn fetch_cats(how_many: u32) -> Vec<String> { vec![] }
let (cat_count, set_cat_count) = signal::<u32>(1);
let cats = Resource::new(move || cat_count.get(), |count| fetch_cats(count));
view! {
<div>
<Transition fallback=move || view! { <p>"Loading (Suspense Fallback)..."</p> }>
// you can access a resource synchronously
{move || {
cats.get().map(|data| {
data
.into_iter()
.map(|src| {
view! {
<img src={src}/>
}
})
.collect_view()
})
}
}
// or you can use `Suspend` to read resources asynchronously
{move || Suspend::new(async move {
cats.await
.into_iter()
.map(|src| {
view! {
<img src={src}/>
}
})
.collect_view()
})}
</Transition>
</div>
}§Required Props
- children:
TypedChildren<Chil>
§Optional Props
- fallback:
impl Into<ViewFnOnce>- Will be displayed while resources are pending. By default this is the empty view.
- set_pending:
impl Into<SignalSetter<bool>>- A function that will be called when the component transitions into or out of
the
pendingstate, with its argument indicating whether it is pending (true) or not pending (false).
- A function that will be called when the component transitions into or out of
the
Fields§
§fallback: ViewFnOnceWill be displayed while resources are pending. By default this is the empty view.
set_pending: Option<SignalSetter<bool>>A function that will be called when the component transitions into or out of
the pending state, with its argument indicating whether it is pending (true)
or not pending (false).
children: TypedChildren<Chil>Implementations§
Source§impl<Chil> TransitionProps<Chil>
impl<Chil> TransitionProps<Chil>
Trait Implementations§
Auto Trait Implementations§
impl<Chil> Freeze for TransitionProps<Chil>
impl<Chil> !RefUnwindSafe for TransitionProps<Chil>
impl<Chil> Send for TransitionProps<Chil>
impl<Chil> !Sync for TransitionProps<Chil>
impl<Chil> Unpin for TransitionProps<Chil>
impl<Chil> !UnwindSafe for TransitionProps<Chil>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more