leptos::reactive::prelude

Trait Update

Source
pub trait Update {
    type Value;

    // Required method
    fn try_maybe_update<U>(
        &self,
        fun: impl FnOnce(&mut Self::Value) -> (bool, U),
    ) -> Option<U>;

    // Provided methods
    fn update(&self, fun: impl FnOnce(&mut Self::Value)) { ... }
    fn maybe_update(&self, fun: impl FnOnce(&mut Self::Value) -> bool) { ... }
    fn try_update<U>(
        &self,
        fun: impl FnOnce(&mut Self::Value) -> U,
    ) -> Option<U> { ... }
}
Expand description

Updates the value of a signal by applying a function that updates it in place, notifying its subscribers that the value has changed.

Required Associated Types§

Source

type Value

The type of the value contained in the signal.

Required Methods§

Source

fn try_maybe_update<U>( &self, fun: impl FnOnce(&mut Self::Value) -> (bool, U), ) -> Option<U>

Updates the value of the signal, notifying subscribers if the update function returns (true, _), and returns the value returned by the update function, or None if the signal has already been disposed.

Provided Methods§

Source

fn update(&self, fun: impl FnOnce(&mut Self::Value))

Updates the value of the signal and notifies subscribers.

Source

fn maybe_update(&self, fun: impl FnOnce(&mut Self::Value) -> bool)

Updates the value of the signal, but only notifies subscribers if the function returns true.

Source

fn try_update<U>(&self, fun: impl FnOnce(&mut Self::Value) -> U) -> Option<U>

Updates the value of the signal and notifies subscribers, returning the value that is returned by the update function, or None if the signal has already been disposed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Update for T
where T: Write,

Source§

type Value = <T as Write>::Value