Struct SyncSignal
pub struct SyncSignal<T> { /* private fields */ }Expand description
A thread-safe read-write signal.
Implementations§
§impl<T> SyncSignal<T>
impl<T> SyncSignal<T>
pub fn id(&self) -> Id
pub fn read_only(&self) -> SyncReadSignal<T>
pub fn read_only(&self) -> SyncReadSignal<T>
Create a Getter of this Signal
pub fn write_only(&self) -> SyncWriteSignal<T>
pub fn write_only(&self) -> SyncWriteSignal<T>
Create a Setter of this Signal
§impl<T> SyncSignal<T>
impl<T> SyncSignal<T>
pub fn new(value: T) -> SyncSignal<T>
pub fn new(value: T) -> SyncSignal<T>
Creates a sync signal. When called off the UI thread, the signal is left unscoped, so callers must ensure it is disposed manually.
pub fn new_split(value: T) -> (SyncReadSignal<T>, SyncWriteSignal<T>)
pub fn new_split(value: T) -> (SyncReadSignal<T>, SyncWriteSignal<T>)
Creates a sync signal with separate read/write handles. Off-UI calls leave the signal unscoped; the caller is responsible for disposal.
Trait Implementations§
§impl<T> Clone for SyncSignal<T>
impl<T> Clone for SyncSignal<T>
§fn clone(&self) -> SyncSignal<T>
fn clone(&self) -> SyncSignal<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl<T> Debug for SyncSignal<T>
impl<T> Debug for SyncSignal<T>
§impl<T> Default for SyncSignal<T>
impl<T> Default for SyncSignal<T>
§fn default() -> SyncSignal<T>
fn default() -> SyncSignal<T>
Returns the “default value” for a type. Read more
§impl<T> From<T> for SyncSignal<T>
impl<T> From<T> for SyncSignal<T>
§fn from(value: T) -> SyncSignal<T>
fn from(value: T) -> SyncSignal<T>
Converts to this type from the input type.
§impl<T> PartialEq for SyncSignal<T>
impl<T> PartialEq for SyncSignal<T>
Source§impl<T> Res<T> for SyncSignal<T>
impl<T> Res<T> for SyncSignal<T>
Source§fn get_value(&self, _: &impl DataContext) -> T
fn get_value(&self, _: &impl DataContext) -> T
Returns the value of a resource by value.
fn set_or_bind<F>(self, cx: &mut Context, closure: F)
§impl<T> SignalGet<T> for SyncSignal<T>
impl<T> SignalGet<T> for SyncSignal<T>
§impl<T> SignalRead<T> for SyncSignal<T>
impl<T> SignalRead<T> for SyncSignal<T>
§fn try_read(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
fn try_read(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
If the signal isn’t disposed,
reads the data stored in the Signal and subscribes to the current running effect.
§fn try_read_untracked(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
fn try_read_untracked(&self) -> Option<ReadRef<'_, T>>where
T: 'static,
If the signal isn’t disposed,
reads the data stored in the Signal without subscribing.
§fn read(&self) -> ReadRef<'_, T>where
T: 'static,
fn read(&self) -> ReadRef<'_, T>where
T: 'static,
Reads the data stored in the Signal, subscribing the current running effect.
§fn read_untracked(&self) -> ReadRef<'_, T>where
T: 'static,
fn read_untracked(&self) -> ReadRef<'_, T>where
T: 'static,
Reads the data stored in the Signal without subscribing.
§impl<T> SignalTrack<T> for SyncSignal<T>
impl<T> SignalTrack<T> for SyncSignal<T>
§impl<T> SignalUpdate<T> for SyncSignal<T>
impl<T> SignalUpdate<T> for SyncSignal<T>
§fn set(&self, new_value: T)where
T: 'static,
fn set(&self, new_value: T)where
T: 'static,
Sets the new_value to the Signal and triggers effect run
§fn update(&self, f: impl FnOnce(&mut T))where
T: 'static,
fn update(&self, f: impl FnOnce(&mut T))where
T: 'static,
Update the stored value with the given function and triggers effect run
§fn try_update<O>(&self, f: impl FnOnce(&mut T) -> O) -> Option<O>where
T: 'static,
fn try_update<O>(&self, f: impl FnOnce(&mut T) -> O) -> Option<O>where
T: 'static,
Update the stored value with the given function, triggers effect run,
and returns the value returned by the function
§fn set_if_changed(&self, new_value: T)where
T: PartialEq + 'static,
fn set_if_changed(&self, new_value: T)where
T: PartialEq + 'static,
Sets the new_value to the Signal and triggers effect run only if the value has changed
§impl<T> SignalWith<T> for SyncSignal<T>
impl<T> SignalWith<T> for SyncSignal<T>
fn with<O>(&self, f: impl FnOnce(&T) -> O) -> Owhere
T: 'static,
fn with_untracked<O>(&self, f: impl FnOnce(&T) -> O) -> Owhere
T: 'static,
fn try_with<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> Owhere
T: 'static,
fn try_with_untracked<O>(&self, f: impl FnOnce(Option<&T>) -> O) -> Owhere
T: 'static,
§impl<T> SignalWrite<T> for SyncSignal<T>
impl<T> SignalWrite<T> for SyncSignal<T>
impl<T> Copy for SyncSignal<T>
impl<T> Eq for SyncSignal<T>
Auto Trait Implementations§
impl<T> Freeze for SyncSignal<T>
impl<T> RefUnwindSafe for SyncSignal<T>where
T: RefUnwindSafe,
impl<T> Send for SyncSignal<T>where
T: Send,
impl<T> Sync for SyncSignal<T>where
T: Sync,
impl<T> Unpin for SyncSignal<T>where
T: Unpin,
impl<T> UnwindSafe for SyncSignal<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.