pub struct WatchedCore<'ctx, T: ?Sized, O: ?Sized = DefaultOwner> { /* private fields */ }Expand description
This represents some value which will be interesting to watch. Watcher functions that reference this value will be re-run when this value changes.
Implementations§
Source§impl<'ctx, T, O: ?Sized> WatchedCore<'ctx, T, O>
impl<'ctx, T, O: ?Sized> WatchedCore<'ctx, T, O>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the WatchedCore, returning the wrapped value
Sourcepub fn replace(&mut self, value: T, ctx: WatchArg<'_, 'ctx, O>) -> T
pub fn replace(&mut self, value: T, ctx: WatchArg<'_, 'ctx, O>) -> T
Takes the wrapped value, with a new one, returning the old value, without deinitializing either one, and notifies watchers that the value has changed.
pub fn replace_external(&mut self, value: T) -> T
Sourcepub fn take(&mut self, ctx: WatchArg<'_, 'ctx, O>) -> Twhere
T: Default,
pub fn take(&mut self, ctx: WatchArg<'_, 'ctx, O>) -> Twhere
T: Default,
Takes the wrapped value, leaving Default::default() in its place,
and notifies watchers that the value has changed.
pub fn take_external(&mut self) -> Twhere
T: Default,
Sourcepub fn set_if_neq(&mut self, value: T, ctx: WatchArg<'_, 'ctx, O>)where
T: PartialEq,
pub fn set_if_neq(&mut self, value: T, ctx: WatchArg<'_, 'ctx, O>)where
T: PartialEq,
This function provides a way to set a value for a watched value only if is has changed. This is useful for cases where setting a value would otherwise cause an infinite loop.
pub fn set_if_neq_external(&mut self, value: T)where
T: PartialEq,
Source§impl<'ctx, T: ?Sized, O: ?Sized> WatchedCore<'ctx, T, O>
impl<'ctx, T: ?Sized, O: ?Sized> WatchedCore<'ctx, T, O>
Sourcepub fn get(&self, ctx: WatchArg<'_, 'ctx, O>) -> &T
pub fn get(&self, ctx: WatchArg<'_, 'ctx, O>) -> &T
Get a referenced to the wrapped value, binding a watch closure.
Sourcepub fn get_mut(&mut self, ctx: WatchArg<'_, 'ctx, O>) -> &mut T
pub fn get_mut(&mut self, ctx: WatchArg<'_, 'ctx, O>) -> &mut T
Get a mutable referenced to the wrapped value, notifying watchers that the value has changed.
pub fn get_mut_external(&mut self) -> &mut T
Sourcepub fn get_unwatched(&self) -> &T
pub fn get_unwatched(&self) -> &T
Get a referenced to the wrapped value, without binding any watch closure.
Source§impl<T: ?Sized> WatchedCore<'static, T, DefaultOwner>
impl<T: ?Sized> WatchedCore<'static, T, DefaultOwner>
pub fn get_auto(&self) -> &T
pub fn get_mut_auto(&mut self) -> &mut T
pub fn replace_auto(&mut self, value: T) -> Twhere
T: Sized,
pub fn take_auto(&mut self) -> Twhere
T: Default,
Sourcepub fn set_if_neq_auto(&mut self, value: T)
pub fn set_if_neq_auto(&mut self, value: T)
This function provides a way to set a value for a watched value only if is has changed. This is useful for cases where setting a value would otherwise cause an infinite loop.