pub struct ArcReadSignal<T> { /* private fields */ }Expand description
A reference-counted getter for a reactive signal.
A signal is a piece of data that may change over time, and notifies other code when it has changed.
This is a reference-counted signal, which is Clone but not Copy.
For arena-allocated Copy signals, use ReadSignal.
§Core Trait Implementations
.get()clones the current value of the signal. If you call it within an effect, it will cause that effect to subscribe to the signal, and to re-run whenever the value of the signal changes..get_untracked()clones the value of the signal without reactively tracking it.
.read()returns a guard that allows accessing the value of the signal by reference. If you call it within an effect, it will cause that effect to subscribe to the signal, and to re-run whenever the value of the signal changes..read_untracked()gives access to the current value of the signal without reactively tracking it.
.with()allows you to reactively access the signal’s value without cloning by applying a callback function..with_untracked()allows you to access the signal’s value by applying a callback function without reactively tracking it.
.to_stream()converts the signal to anasyncstream of values.::from_stream()converts anasyncstream of values into a signal containing the latest value.
§Examples
let (count, set_count) = arc_signal(0);
// calling .get() clones and returns the value
assert_eq!(count.get(), 0);
// calling .read() accesses the value by reference
assert_eq!(count.read(), 0);Trait Implementations§
Source§impl<T> Clone for ArcReadSignal<T>
impl<T> Clone for ArcReadSignal<T>
Source§impl<T> Debug for ArcReadSignal<T>
impl<T> Debug for ArcReadSignal<T>
Source§impl<T: Default> Default for ArcReadSignal<T>
impl<T: Default> Default for ArcReadSignal<T>
Source§impl<T> DefinedAt for ArcReadSignal<T>
impl<T> DefinedAt for ArcReadSignal<T>
Source§fn defined_at(&self) -> Option<&'static Location<'static>>
fn defined_at(&self) -> Option<&'static Location<'static>>
Returns the location at which the signal was defined. This is usually simply
None in
release mode.Source§impl<T> Fn() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature nightly only.
impl<T> Fn() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature
nightly only.Source§impl<T> FnMut() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature nightly only.
impl<T> FnMut() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature
nightly only.Source§impl<T> FnOnce() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature nightly only.
impl<T> FnOnce() for ArcReadSignal<T>where
ArcReadSignal<T>: Get,
Available on crate feature
nightly only.Source§impl<T> From<ArcReadSignal<T>> for ArcMemo<T, SyncStorage>
impl<T> From<ArcReadSignal<T>> for ArcMemo<T, SyncStorage>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T: Send + Sync> From<ArcReadSignal<T>> for ArcSignal<T, SyncStorage>
impl<T: Send + Sync> From<ArcReadSignal<T>> for ArcSignal<T, SyncStorage>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<ArcReadSignal<T>> for MaybeSignal<T>
impl<T> From<ArcReadSignal<T>> for MaybeSignal<T>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<ArcReadSignal<T>> for Memo<T>
impl<T> From<ArcReadSignal<T>> for Memo<T>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<ArcReadSignal<T>> for ReadSignal<T>
impl<T> From<ArcReadSignal<T>> for ReadSignal<T>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<ArcReadSignal<T>> for Signal<T>
impl<T> From<ArcReadSignal<T>> for Signal<T>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T> From<ArcReadSignal<T>> for Signal<T, LocalStorage>
impl<T> From<ArcReadSignal<T>> for Signal<T, LocalStorage>
Source§fn from(value: ArcReadSignal<T>) -> Self
fn from(value: ArcReadSignal<T>) -> Self
Converts to this type from the input type.
Source§impl<T, S> From<ReadSignal<T, S>> for ArcReadSignal<T>where
T: 'static,
S: Storage<ArcReadSignal<T>>,
impl<T, S> From<ReadSignal<T, S>> for ArcReadSignal<T>where
T: 'static,
S: Storage<ArcReadSignal<T>>,
Source§fn from(value: ReadSignal<T, S>) -> Self
fn from(value: ReadSignal<T, S>) -> Self
Converts to this type from the input type.
Source§impl<T> FromLocal<ArcReadSignal<T>> for MaybeSignal<T, LocalStorage>
impl<T> FromLocal<ArcReadSignal<T>> for MaybeSignal<T, LocalStorage>
Source§fn from_local(value: ArcReadSignal<T>) -> Self
fn from_local(value: ArcReadSignal<T>) -> Self
Converts between the types.
Source§impl<T> FromLocal<ArcReadSignal<T>> for ReadSignal<T, LocalStorage>where
T: 'static,
impl<T> FromLocal<ArcReadSignal<T>> for ReadSignal<T, LocalStorage>where
T: 'static,
Source§fn from_local(value: ArcReadSignal<T>) -> Self
fn from_local(value: ArcReadSignal<T>) -> Self
Converts between the types.
Source§impl<T> Hash for ArcReadSignal<T>
impl<T> Hash for ArcReadSignal<T>
Source§impl<T> IntoInner for ArcReadSignal<T>
impl<T> IntoInner for ArcReadSignal<T>
Source§impl<T> IsDisposed for ArcReadSignal<T>
impl<T> IsDisposed for ArcReadSignal<T>
Source§fn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
If
true, the signal cannot be accessed without a panic.Source§impl<T> PartialEq for ArcReadSignal<T>
impl<T> PartialEq for ArcReadSignal<T>
Source§impl<T: 'static> ReadUntracked for ArcReadSignal<T>
impl<T: 'static> ReadUntracked for ArcReadSignal<T>
Source§type Value = ReadGuard<T, Plain<T>>
type Value = ReadGuard<T, Plain<T>>
The guard type that will be returned, which can be dereferenced to the value.
Source§fn try_read_untracked(&self) -> Option<Self::Value>
fn try_read_untracked(&self) -> Option<Self::Value>
Returns the guard, or
None if the signal has already been disposed.Source§fn read_untracked(&self) -> Self::Value
fn read_untracked(&self) -> Self::Value
Returns the guard. Read more
Source§fn custom_try_read(&self) -> Option<Option<Self::Value>>
fn custom_try_read(&self) -> Option<Option<Self::Value>>
This is a backdoor to allow overriding the
Read::try_read implementation despite it being auto implemented. Read moreSource§impl<T: Serialize + 'static> Serialize for ArcReadSignal<T>
impl<T: Serialize + 'static> Serialize for ArcReadSignal<T>
impl<T> Eq for ArcReadSignal<T>
Auto Trait Implementations§
impl<T> Freeze for ArcReadSignal<T>
impl<T> RefUnwindSafe for ArcReadSignal<T>
impl<T> Send for ArcReadSignal<T>
impl<T> Sync for ArcReadSignal<T>
impl<T> Unpin for ArcReadSignal<T>
impl<T> UnwindSafe for ArcReadSignal<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<S, T> FromStream<T> for S
impl<S, T> FromStream<T> for S
Source§fn from_stream(stream: impl Stream<Item = T> + Send + 'static) -> S
fn from_stream(stream: impl Stream<Item = T> + Send + 'static) -> S
Creates a signal that contains the latest value of the stream.
Source§fn from_stream_unsync(stream: impl Stream<Item = T> + 'static) -> S
fn from_stream_unsync(stream: impl Stream<Item = T> + 'static) -> S
Creates a signal that contains the latest value of the stream.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ReactiveNode for Twhere
T: AsSubscriberSet + DefinedAt,
impl<T> ReactiveNode for Twhere
T: AsSubscriberSet + DefinedAt,
Source§fn mark_dirty(&self)
fn mark_dirty(&self)
Notifies the source’s dependencies that it has changed.
Source§fn mark_check(&self)
fn mark_check(&self)
Notifies the source’s dependencies that it may have changed.
Source§fn mark_subscribers_check(&self)
fn mark_subscribers_check(&self)
Marks that all subscribers need to be checked.
Source§fn update_if_necessary(&self) -> bool
fn update_if_necessary(&self) -> bool
Regenerates the value for this node, if needed, and returns whether
it has actually changed or not.
Source§impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read for Twhere
T: Track + ReadUntracked,
Source§impl<T> Source for Twhere
T: AsSubscriberSet + DefinedAt,
impl<T> Source for Twhere
T: AsSubscriberSet + DefinedAt,
Source§fn clear_subscribers(&self)
fn clear_subscribers(&self)
Remove all subscribers from this source’s list of dependencies.
Source§fn add_subscriber(&self, subscriber: AnySubscriber)
fn add_subscriber(&self, subscriber: AnySubscriber)
Adds a subscriber to this source’s list of dependencies.
Source§fn remove_subscriber(&self, subscriber: &AnySubscriber)
fn remove_subscriber(&self, subscriber: &AnySubscriber)
Removes a subscriber from this source’s list of dependencies.
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.
Source§impl<T> With for Twhere
T: Read,
impl<T> With for Twhere
T: Read,
Source§type Value = <<T as Read>::Value as Deref>::Target
type Value = <<T as Read>::Value as Deref>::Target
The type of the value contained in the signal.
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
Source§type Value = <<T as ReadUntracked>::Value as Deref>::Target
type Value = <<T as ReadUntracked>::Value as Deref>::Target
The type of the value contained in the signal.
Source§fn try_with_untracked<U>(
&self,
fun: impl FnOnce(&<T as WithUntracked>::Value) -> U,
) -> Option<U>
fn try_with_untracked<U>( &self, fun: impl FnOnce(&<T as WithUntracked>::Value) -> U, ) -> Option<U>
Applies the closure to the value, and returns the result,
or
None if the signal has already been disposed.