Struct dioxus_shareables::shared::Shared
source · [−]Expand description
A hook to a shared_value.
This is generally created by calling use_rw or use_w on a shareable!, or by
calling ListEntry::use_rw or
ListEntry::use_w.
Fields
id: Option<usize>Implementations
sourcepub fn init<P, F: FnOnce() -> T>(
cx: &Scope<'_, P>,
opt: &mut Shareable<T>,
f: F,
_: B
) -> Self
pub fn init<P, F: FnOnce() -> T>(
cx: &Scope<'_, P>,
opt: &mut Shareable<T>,
f: F,
_: B
) -> Self
Initialize the hook in scope cx.
The shared value will be initialized with f() if it hasn’t been created yet.
NOTE: this method should generally not be used directly; instead, shared values are usually
created with shareable!.
sourcepub fn write(&self) -> RefMut<'_, T>
pub fn write(&self) -> RefMut<'_, T>
Obtain a write pointer to the shared value and register the change.
This will mark all components which hold a RW link to the value as needing update.
sourcepub fn write_silent(&self) -> RefMut<'_, T>
pub fn write_silent(&self) -> RefMut<'_, T>
Obtain a write pointer to the shared value but do not register the change.
This will not notify consumers of the change to the value.
sourcepub fn needs_update(&self)
pub fn needs_update(&self)
Mark the components which hold a RW link to the value as needing update.
sourcepub fn set(&self, t: T)where
T: PartialEq,
pub fn set(&self, t: T)where
T: PartialEq,
Set the shared value.
This marks compoments which hold a RW link to the value as needing update if and only if the value has changed.
sourcepub fn set_with<F: Fn(&T) -> T>(&self, f: F)where
T: PartialEq,
pub fn set_with<F: Fn(&T) -> T>(&self, f: F)where
T: PartialEq,
Set the shared value to f(&x) where x is the current value.
This marks components which hold a RW link to the value as needing update if and only if the value has changed.
pub fn listeners<'a>(&'a self) -> String
Trait Implementations
Auto Trait Implementations
Blanket Implementations
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more