pub struct AwaitProps<T, Fut, Chil, V>where
T: Send + Sync + Serialize + DeserializeOwned + 'static,
Fut: Future<Output = T> + Send + 'static,
Chil: FnOnce(&T) -> V + Send + 'static,
V: IntoView + 'static,{
pub future: Fut,
pub blocking: bool,
pub children: Chil,
}Expand description
Props for the Await component.
Allows you to inline the data loading for an async block or
server function directly into your view. This is the equivalent of combining a
[create_resource] that only loads once (i.e., with a source signal || ()) with
a Suspense with no fallback.
Adding let:{variable name} to the props makes the data available in the children
that variable name, when resolved.
async fn fetch_monkeys(monkey: i32) -> i32 {
// do some expensive work
3
}
view! {
<Await
future=fetch_monkeys(3)
let:data
>
<p>{*data} " little monkeys, jumping on the bed."</p>
</Await>
}§Required Props
- future: [
Fut]- A
Futurethat will the component will.awaitbefore rendering.
- A
- children: [
Chil]-
A function that takes a reference to the resolved data from the
futurerenders a view.§Syntax
This can be passed in the
viewchildren of the<Await/>by using thelet:syntax to specify the name for the data variable.view! { <Await future=fetch_monkeys(3) let:data > <p>{*data} " little monkeys, jumping on the bed."</p> </Await> }is the same as
view! { <Await future=fetch_monkeys(3) children=|data| view! { <p>{*data} " little monkeys, jumping on the bed."</p> } /> }
-
§Optional Props
- blocking:
bool- If
true, the component will create a blocking resource, preventing the HTML stream from returning anything beforefuturehas resolved.
- If
Fields§
§future: FutA Future that will the component will .await
before rendering.
blocking: boolIf true, the component will create a blocking resource, preventing
the HTML stream from returning anything before future has resolved.
children: ChilA function that takes a reference to the resolved data from the future
renders a view.
§Syntax
This can be passed in the view children of the <Await/> by using the
let: syntax to specify the name for the data variable.
view! {
<Await
future=fetch_monkeys(3)
let:data
>
<p>{*data} " little monkeys, jumping on the bed."</p>
</Await>
}is the same as
view! {
<Await
future=fetch_monkeys(3)
children=|data| view! {
<p>{*data} " little monkeys, jumping on the bed."</p>
}
/>
}Implementations§
Source§impl<T, Fut, Chil, V> AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> AwaitProps<T, Fut, Chil, V>
Trait Implementations§
Source§impl<T, Fut, Chil, V> Props for AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> Props for AwaitProps<T, Fut, Chil, V>
Auto Trait Implementations§
impl<T, Fut, Chil, V> Freeze for AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> RefUnwindSafe for AwaitProps<T, Fut, Chil, V>where
Fut: RefUnwindSafe,
Chil: RefUnwindSafe,
impl<T, Fut, Chil, V> Send for AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> Sync for AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> Unpin for AwaitProps<T, Fut, Chil, V>
impl<T, Fut, Chil, V> UnsafeUnpin for AwaitProps<T, Fut, Chil, V>where
Fut: UnsafeUnpin,
Chil: UnsafeUnpin,
impl<T, Fut, Chil, V> UnwindSafe for AwaitProps<T, Fut, Chil, V>where
Fut: UnwindSafe,
Chil: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.