Trait frappe::Signal
[−]
[src]
pub trait Signal<T>: Clone + 'static { fn sample(&self) -> T; fn sample_with<F, R>(&self, cb: F) -> R
where
F: FnOnce(Cow<T>) -> R; fn map<F, R>(&self, f: F) -> SignalFn<R>
where
F: Fn(Cow<T>) -> R + 'static,
R: Clone,
T: Clone + 'static, { ... } fn snapshot<S, F, R>(&self, trigger: &Stream<S>, f: F) -> Stream<R>
where
F: Fn(Cow<T>, Cow<S>) -> R + 'static,
S: Clone + 'static,
R: Clone + 'static,
T: Clone + 'static, { ... } fn switch<U>(&self) -> SignalNested<U>
where
T: Signal<U> + Into<SignalAny<U>>,
U: Clone, { ... } }
Represents a continuous value that changes over time.
Required Methods
fn sample(&self) -> T
Sample by value.
This will clone the content of the signal.
fn sample_with<F, R>(&self, cb: F) -> R where
F: FnOnce(Cow<T>) -> R,
F: FnOnce(Cow<T>) -> R,
Sample by reference.
This is meant to be the most efficient way when cloning is undesirable,
but it requires a callback to prevent outliving internal RwLock
borrows.
Provided Methods
fn map<F, R>(&self, f: F) -> SignalFn<R> where
F: Fn(Cow<T>) -> R + 'static,
R: Clone,
T: Clone + 'static,
F: Fn(Cow<T>) -> R + 'static,
R: Clone,
T: Clone + 'static,
Maps a signal with the provided function.
fn snapshot<S, F, R>(&self, trigger: &Stream<S>, f: F) -> Stream<R> where
F: Fn(Cow<T>, Cow<S>) -> R + 'static,
S: Clone + 'static,
R: Clone + 'static,
T: Clone + 'static,
F: Fn(Cow<T>, Cow<S>) -> R + 'static,
S: Clone + 'static,
R: Clone + 'static,
T: Clone + 'static,
Samples the value of this signal every time the trigger stream fires.
fn switch<U>(&self) -> SignalNested<U> where
T: Signal<U> + Into<SignalAny<U>>,
U: Clone,
T: Signal<U> + Into<SignalAny<U>>,
U: Clone,
Creates a new signal that samples the inner value of a nested signal.
Implementors
impl<T: Clone + 'static> Signal<T> for SignalConst<T>
impl<T: Clone + 'static> Signal<T> for SignalShared<T>
impl<T: Clone + 'static> Signal<T> for SignalFn<T>
impl<T: Clone + 'static> Signal<T> for SignalNested<T>
impl<T: Clone + 'static> Signal<T> for SignalAny<T>