Fix issue with mutability in component macro

This commit is contained in:
Jonathan Kelley committed 2024-01-15 23:57:10 -08:00
1 parent 8559984e9d
commit 98bd78de43
5 files changed
+47 -22

No files matched your search

+10 -8
View File
@@ -245,7 +245,17 @@ impl<T: 'static> Signal<T> {
GenerationalRef::map(inner, |v| &v.value)
}
/// Get a mutable reference to the signal's value.
///
/// If the signal has been dropped, this will panic.
#[track_caller]
pub fn write<'a>(&'a mut self) -> Write<'a, T> {
self.write_unchecked()
}
/// Write to the value through an immutable reference.
///
/// This is public since it's useful in many scenarios, but we generally recommend mutation through [`Self::write`] instead.
pub fn write_unchecked(&self) -> Write<T> {
let inner = self.inner.write();
let borrow = GenerationalRefMut::map(inner, |v| &mut v.value);
@@ -255,14 +265,6 @@ impl<T: 'static> Signal<T> {
}
}
/// Get a mutable reference to the signal's value.
///
/// If the signal has been dropped, this will panic.
#[track_caller]
pub fn write<'a>(&'a mut self) -> Write<'a, T> {
self.write_unchecked()
}
fn update_subscribers(&self) {
{
let inner = self.inner.read();