[−][src]Struct rt_graph::observable_value::ObservableValue
A value that implements the Observer pattern.
Consumers can connect to receive callbacks when the value changes.
Implementations
impl<T> ObservableValue<T> where
T: Clone,
[src]
T: Clone,
pub fn new(initial_value: T) -> ObservableValue<T>
[src]
Construct an ObservableValue
.
pub fn get(&self) -> &T
[src]
Get the current value
pub fn set(&mut self, new_value: &T)
[src]
Set a new value and notify all connected subscribers.
pub fn connect<F>(&mut self, callback: F) -> SubscriptionId where
F: Fn(&T) + 'static,
[src]
F: Fn(&T) + 'static,
Connect a new subscriber that will receive callbacks when the value is set.
Returns a SubscriptionId to disconnect the subscription when no longer required.
pub fn disconnect(&mut self, sub_id: SubscriptionId)
[src]
Disconnect an existing subscription.
pub fn split(self) -> (ReadHalf<T>, WriteHalf<T>)
[src]
Divide this instance into a read half (can listen for updates, but cannot write new values) and a write half (can write new values).
Auto Trait Implementations
impl<T> !RefUnwindSafe for ObservableValue<T>
impl<T> !Send for ObservableValue<T>
impl<T> !Sync for ObservableValue<T>
impl<T> Unpin for ObservableValue<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for ObservableValue<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,