Skip to main content

Watchable

Trait Watchable 

Source
pub trait Watchable<T>:
    Clone
    + Gettable<T>
    + DepNode
    + Sized
    + Send
    + Sync
    + 'static {
    // Required methods
    fn subscribe(
        &self,
        callback: impl Fn(&Signal<T>) + Send + Sync + 'static,
    ) -> SubscriptionGuard;
    fn unsubscribe(&self, id: Uuid);
    fn is_complete(&self) -> bool;
    fn is_error(&self) -> bool;
    fn error(&self) -> Option<Arc<Error>>;
}
Expand description

Core reactive cell trait - subscribe to changes.

Required Methods§

Source

fn subscribe( &self, callback: impl Fn(&Signal<T>) + Send + Sync + 'static, ) -> SubscriptionGuard

Subscribe to all signals (values, completion, errors). Returns a guard that unsubscribes when dropped.

The callback must not panic. Cell::notify walks subscribers in order and does not isolate panics — a panicking subscriber propagates out of the set/send call that triggered the notification and prevents later subscribers in the same fanout from observing the signal, leaving the reactive graph in a partially-updated state. Keep subscribers pure and fast; handle expected errors inside the callback.

Source

fn unsubscribe(&self, id: Uuid)

Unsubscribe by ID (for internal use).

Source

fn is_complete(&self) -> bool

Returns true if this cell has completed (no more values will be emitted).

Source

fn is_error(&self) -> bool

Returns true if this cell has errored.

Source

fn error(&self) -> Option<Arc<Error>>

Returns the error if this cell has errored.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: CellValue, U: Send + Sync + 'static> Watchable<T> for Cell<T, U>

Source§

impl<T: CellValue> Watchable<T> for BoundedInput<T>