pub struct MutableState<T: Clone + 'static> { /* private fields */ }Implementations§
Source§impl<T: Clone + 'static> MutableState<T>
impl<T: Clone + 'static> MutableState<T>
pub fn with_runtime(value: T, runtime: RuntimeHandle) -> Self
pub fn as_state(&self) -> State<T>
pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn update<R>(&self, f: impl FnOnce(&mut T) -> R) -> R
pub fn replace(&self, value: T)
pub fn set_value(&self, value: T)
pub fn set(&self, value: T)
pub fn value(&self) -> T
pub fn get(&self) -> T
Sourcepub fn get_non_reactive(&self) -> T
pub fn get_non_reactive(&self) -> T
Gets the current value WITHOUT subscribing to recomposition.
Use this in layout/measure/draw phases to read state without causing the current composition scope to recompose when the state changes.
§When to use
- In modifier nodes (like ScrollNode) during measure()
- In any layout phase code that reads state but shouldn’t trigger recomposition
§When NOT to use
- In composable functions that should update when state changes
- When you want reactive UI updates
Trait Implementations§
Source§impl<T: Clone + Clone + 'static> Clone for MutableState<T>
impl<T: Clone + Clone + 'static> Clone for MutableState<T>
Source§fn clone(&self) -> MutableState<T>
fn clone(&self) -> MutableState<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Clone + 'static> PartialEq for MutableState<T>
impl<T: Clone + 'static> PartialEq for MutableState<T>
impl<T: Clone + 'static> Copy for MutableState<T>
impl<T: Clone + 'static> Eq for MutableState<T>
Auto Trait Implementations§
impl<T> Freeze for MutableState<T>
impl<T> RefUnwindSafe for MutableState<T>
impl<T> Send for MutableState<T>
impl<T> Sync for MutableState<T>
impl<T> Unpin for MutableState<T>
impl<T> UnwindSafe for MutableState<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more