[−][src]Struct frappe::signal::Signal
Represents a value that changes over time.
Methods
impl<T> Signal<T>
[src]
pub fn constant(val: T) -> Self where
T: Clone + Send + Sync + 'static,
[src]
T: Clone + Send + Sync + 'static,
Creates a signal with constant value.
pub fn from_fn<F>(f: F) -> Self where
F: Fn() -> T + Send + Sync + 'static,
[src]
F: Fn() -> T + Send + Sync + 'static,
Creates a signal that samples it's values from an external source.
pub fn sample(&self) -> T
[src]
Samples the value of the signal.
The action of sampling pulls the value through the signal chain until it finds it's source, clones it if necessary, and then transforms it into the result value.
pub fn map<F, R>(&self, f: F) -> Signal<R> where
F: Fn(T) -> R + Send + Sync + 'static,
T: 'static,
[src]
F: Fn(T) -> R + Send + Sync + 'static,
T: 'static,
Maps a signal using the provided function.
The map operation applies the function to the signal value every time it's sampled.
pub fn fold<A, F>(&self, initial: A, f: F) -> Signal<A> where
F: Fn(A, T) -> A + Send + Sync + 'static,
T: 'static,
A: Clone + Send + Sync + 'static,
[src]
F: Fn(A, T) -> A + Send + Sync + 'static,
T: 'static,
A: Clone + Send + Sync + 'static,
Folds a signal using the provided function.
The fold operation applies a Fn(A, T) -> A
function on the signal every time it's sampled,
where A
is the current accumulator value and T
is the value of the input signal.
The result of this call is stored on the accumulator and returned as the output signal's
value.
pub fn snapshot<S, F, R>(&self, trigger: &Stream<S>, f: F) -> Stream<R> where
F: Fn(T, MaybeOwned<S>) -> R + Send + Sync + 'static,
T: 'static,
S: 'static,
R: 'static,
[src]
F: Fn(T, MaybeOwned<S>) -> R + Send + Sync + 'static,
T: 'static,
S: 'static,
R: 'static,
Samples the value of this signal every time the trigger stream fires.
pub fn from_channel(initial: T, rx: Receiver<T>) -> Self where
T: Clone + Send + Sync + 'static,
[src]
T: Clone + Send + Sync + 'static,
Stores the last value sent to a channel.
When sampled, the resulting signal consumes all the current values on the channel
(using try_recv
) and returns the last value seen.
pub fn fold_channel<V, F>(initial: T, rx: Receiver<V>, f: F) -> Self where
F: Fn(T, V) -> T + Send + Sync + 'static,
T: Clone + Send + Sync + 'static,
V: Send + 'static,
[src]
F: Fn(T, V) -> T + Send + Sync + 'static,
T: Clone + Send + Sync + 'static,
V: Send + 'static,
Creates a signal that folds the values from a channel.
When sampled, the resulting signal consumes all the current values on the channel
(using try_recv
) and folds them using the current signal value as the
initial accumulator state.
pub fn cyclic<F>(definition: F) -> Self where
F: FnOnce(&Signal<T>) -> Signal<T>,
T: 'static,
[src]
F: FnOnce(&Signal<T>) -> Signal<T>,
T: 'static,
Creates a signal with a cyclic definition.
This allows creating a self-referential Signal definition. The closure receives a forward declaration of a signal that must be used to construct the final Signal. Then this previous forward-declaration is replaced with the value returned by the closure.
Sampling the forward-declared signal will cause a panic.
impl<T: 'static> Signal<Signal<T>>
[src]
pub fn switch(&self) -> Signal<T>
[src]
Creates a new signal that samples the inner value of a nested signal.
Trait Implementations
impl<T> Clone for Signal<T>
[src]
fn clone(&self) -> Self
[src]
Creates a new signal that references the same value.
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Default + 'static> Default for Signal<T>
[src]
impl<T: Clone + Send + Sync + 'static> From<T> for Signal<T>
[src]
impl<T: Display> Display for Signal<T>
[src]
impl<T> Debug for Signal<T>
[src]
Auto Trait Implementations
impl<T> Unpin for Signal<T>
impl<T> Sync for Signal<T>
impl<T> Send for Signal<T>
impl<T> !UnwindSafe for Signal<T>
impl<T> !RefUnwindSafe for Signal<T>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
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.
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,