pub trait Source {
type Value;
// Required method
fn read(&self) -> Self::Value;
}Expand description
Anything a derivation — or a widget — can read reactively: either handle on a signal, or a value already derived once.
One trait rather than a derive/derive_from/map family, because the difference between them was never
about behaviour: a widget reading a service, a read handle, or something derived all want the same thing,
and three spellings of it only meant picking the wrong one and chasing a type error.
A widget that takes impl Source<Value = T> instead of RwSignal<T> can be fed a derivation. One that
takes the signal cannot, and that is how a catalogue ends up re-implemented next to it — a card wanting a
percentage computed from two services has nothing to hand a widget that insists on a signal it can write.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Source for f32
A plain value reads as itself, so a widget taking a Source still accepts a constant without the caller
wrapping it in a signal that will never change.
impl Source for f32
A plain value reads as itself, so a widget taking a Source still accepts a constant without the caller
wrapping it in a signal that will never change.