pub trait Signal: Clone + 'static {
type Output: 'static;
type Guard: WatcherGuard;
// Required methods
fn get(&self) -> Self::Output;
fn watch(
&self,
watcher: impl Fn(Context<Self::Output>) + 'static,
) -> Self::Guard;
// Provided method
fn identity(&self) -> Option<SignalIdentity> { ... }
}Expand description
The core trait for reactive system.
Types implementing Signal represent a computation that can produce a value
and notify observers when that value changes.
Required Associated Types§
Sourcetype Guard: WatcherGuard
type Guard: WatcherGuard
The guard type returned by the watch method that manages watcher lifecycle.
Required Methods§
Provided Methods§
Sourcefn identity(&self) -> Option<SignalIdentity>
fn identity(&self) -> Option<SignalIdentity>
Returns the stable semantic identity of this signal, when one exists.
Constant signals intentionally return None because they do not own
observable state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".