From 2bab4eb6c3748ca8803a1332ff57502979da7e55 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 7 Dec 2023 07:06:43 -0600 Subject: [PATCH] rename read_untracked to peak --- packages/signals/src/signal.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/signals/src/signal.rs b/packages/signals/src/signal.rs index 0ad96349d..88853c473 100644 --- a/packages/signals/src/signal.rs +++ b/packages/signals/src/signal.rs @@ -171,7 +171,8 @@ impl Signal { self.inner.origin_scope() } - /// Get the current value of the signal. This will subscribe the current scope to the signal. + /// Get the current value of the signal. This will subscribe the current scope to the signal. If you would like to read the signal without subscribing to it, you can use [`Self::peak`] instead. + /// /// If the signal has been dropped, this will panic. pub fn read(&self) -> Ref { let inner = self.inner.read(); @@ -201,13 +202,15 @@ impl Signal { } /// 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 read_untracked(&self) -> Ref { + pub fn peak(&self) -> Ref { let inner = self.inner.read(); Ref::map(inner, |v| &v.value) } /// Get a mutable reference to the signal's value. + /// /// If the signal has been dropped, this will panic. pub fn write(&self) -> Write<'_, T> { let inner = self.inner.write(); @@ -387,15 +390,18 @@ impl ReadOnlySignal { self.inner.origin_scope() } - /// Get the current value of the signal. This will subscribe the current scope to the signal. + /// Get the current value of the signal. This will subscribe the current scope to the signal. If you would like to read the signal without subscribing to it, you can use [`Self::peak`] instead. + /// + /// If the signal has been dropped, this will panic. pub fn read(&self) -> Ref { self.inner.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 read_untracked(&self) -> Ref { - self.inner.read_untracked() + pub fn peak(&self) -> Ref { + self.inner.peak() } /// Run a closure with a reference to the signal's value.