mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-03 17:39:11 +00:00
Added .with_mut_silent()
fn
This commit is contained in:
parent
7c6a7f64cb
commit
0df6a8f2ac
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,7 @@ use std::{
|
||||||
cell::{Ref, RefCell, RefMut},
|
cell::{Ref, RefCell, RefMut},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
use std::ops::DerefMut;
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
@ -70,6 +71,12 @@ impl<T: 'static> UseAtomRef<T> {
|
||||||
self.value.borrow()
|
self.value.borrow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This is silent operation
|
||||||
|
/// call `.force_update()` manually if required
|
||||||
|
pub fn with_mut_silent(&self, cb: impl FnOnce(&mut T)) {
|
||||||
|
cb(self.write_silent().deref_mut())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn write(&self) -> RefMut<T> {
|
pub fn write(&self) -> RefMut<T> {
|
||||||
self.root.force_update(self.ptr);
|
self.root.force_update(self.ptr);
|
||||||
self.value.borrow_mut()
|
self.value.borrow_mut()
|
||||||
|
|
Loading…
Reference in a new issue