diff --git a/packages/signals/src/global.rs b/packages/signals/src/global.rs index efc503007..fe0f77f86 100644 --- a/packages/signals/src/global.rs +++ b/packages/signals/src/global.rs @@ -43,7 +43,8 @@ impl GlobalSignal { GlobalSignal { initializer } } - fn inner_signal(&self) -> Signal { + /// Get the signal that backs this global. + pub fn signal(&self) -> Signal { let key = self as *const _ as *const (); let context = get_global_context(); @@ -68,14 +69,14 @@ impl GlobalSignal { /// If the signal has been dropped, this will panic. #[track_caller] pub fn read(&self) -> GenerationalRef> { - self.inner_signal().read() + self.signal().read() } /// Get the current value of the signal. **Unlike read, this will not subscribe the current scope to the signal which can cause parts of your UI to not update.** /// /// If the signal has been dropped, this will panic. pub fn peek(&self) -> GenerationalRef> { - self.inner_signal().peek() + self.signal().peek() } /// Get a mutable reference to the signal's value. @@ -83,33 +84,33 @@ impl GlobalSignal { /// If the signal has been dropped, this will panic. #[track_caller] pub fn write(&self) -> Write>> { - self.inner_signal().write() + self.signal().write() } /// Set the value of the signal. This will trigger an update on all subscribers. #[track_caller] pub fn set(&self, value: T) { - self.inner_signal().set(value); + self.signal().set(value); } /// Set the value of the signal without triggering an update on subscribers. #[track_caller] pub fn set_untracked(&self, value: T) { - self.inner_signal().set_untracked(value); + self.signal().set_untracked(value); } /// Run a closure with a reference to the signal's value. /// If the signal has been dropped, this will panic. #[track_caller] pub fn with(&self, f: impl FnOnce(&T) -> O) -> O { - self.inner_signal().with(f) + self.signal().with(f) } /// Run a closure with a mutable reference to the signal's value. /// If the signal has been dropped, this will panic. #[track_caller] pub fn with_mut(&self, f: impl FnOnce(&mut T) -> O) -> O { - self.inner_signal().with_mut(f) + self.signal().with_mut(f) } /// Map the signal to a new type. @@ -117,12 +118,12 @@ impl GlobalSignal { &self, f: impl Fn(&T) -> &O + 'static, ) -> MappedSignal>> { - MappedSignal::new(self.inner_signal(), f) + MappedSignal::new(self.signal(), f) } /// Get the generational id of the signal. pub fn id(&self) -> generational_box::GenerationalBoxId { - self.inner_signal().id() + self.signal().id() } } @@ -131,7 +132,7 @@ where T: Clone + IntoAttributeValue, { fn into_value(self) -> dioxus_core::AttributeValue { - self.inner_signal().into_value() + self.signal().into_value() } }