Enum MaybeDyn Copy item path
Summary pub enum MaybeDyn<T>{
Static(T),
Signal(ReadSignal <T>),
Derived(Rc <dyn Fn () -> MaybeDyn <T>>),
}
Expand description Represents a value that can be either static or dynamic.
This is useful for cases where you want to accept a value that can be either static or dynamic,
such as in component props.
A MaybeDyn
value can be created from a static value or a closure that returns the value by
using the From
trait.
§ Creating a MaybeDyn
You can create a MaybeDyn
from a static value by using the MaybeDyn::Static
variant.
However, most of the times, you probably want to use the implementation of the From<U>
trait
for MaybeDyn<T>
.
This trait is already implemented globally for signals and closures that return T
. However,
we cannot provide a blanket implementation for all types T
to convert into MaybeDyn<T>
because of specialization. Instead, we can only implement it for specific types.
A dynamic value backed by a signal.
Get the value by consuming itself. Unlike get_clone
, this method avoids
a clone if we are just storing a static value.
Get the value by copying it.
If the type does not implement Copy
, consider using get_clone
instead.
Get the value by cloning it.
If the type implements Copy
, consider using get
instead.
Track the reactive dependencies, if it is dynamic.
Tries to get the value statically or returns None
if value is dynamic.
Performs copy-assignment from
source
.
Read more Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Immutably borrows from an owned value.
Read more Mutably borrows from an owned value.
Read more 🔬 This is a nightly-only experimental API. (clone_to_uninit
)
Performs copy-assignment from
self
to
dst
.
Read more Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From <T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more Uses borrowed data to replace owned data, usually by cloning.
Read more The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.