pub struct Dynamic(/* private fields */);Expand description
A dynamic view that can be updated.
Represents a view whose content can be changed dynamically at runtime.
You should avoid using this component if possible,
most of components in WaterUI already provide a way to update their content reactively.
Implementations§
Source§impl Dynamic
impl Dynamic
Sourcepub fn new() -> (DynamicHandler, Self)
pub fn new() -> (DynamicHandler, Self)
Creates a new Dynamic view along with its handler.
Returns a tuple of (handler, view) where the handler can be used to update the view’s content.
§Returns
A tuple containing the DynamicHandler and Dynamic view
Sourcepub fn watch<T, S, V: View>(value: S, f: impl 'static + Fn(T) -> V) -> impl Viewwhere
S: Signal<Output = T>,
pub fn watch<T, S, V: View>(value: S, f: impl 'static + Fn(T) -> V) -> impl Viewwhere
S: Signal<Output = T>,
Creates a Dynamic view that watches a reactive value.
The provided function is used to convert the value to a view. Whenever the watched value changes, the view will update automatically.
§Arguments
value- The reactive value to watchf- A function that converts the value to a view
§Returns
A Dynamic view that updates when the value changes
Sourcepub fn connect(self, receiver: impl Fn(Context<AnyView>) + 'static)
pub fn connect(self, receiver: impl Fn(Context<AnyView>) + 'static)
Connects the Dynamic view to a receiver function.
For internal use only.
The receiver function is called whenever the view content is updated. If there’s a temporary view stored (set before connecting), it will be immediately passed to the receiver.
§Arguments
receiver- A function that receives view updates