Trait silkenweb::value::RefSignalOrValue
source · pub trait RefSignalOrValue<'a> {
type Item: 'a;
type Signal: Signal<Item = Self::Item> + 'a;
type Map<'b: 'a, F: FnMut(Self::Item) -> R + 'b, R: RefSignalOrValue<'b, Item = R> + 'b>: RefSignalOrValue<'b, Item = R> + 'b;
// Required methods
fn map<'b, F, R>(self, callback: F) -> Self::Map<'b, F, R>
where 'b: 'a,
R: RefSignalOrValue<'b, Item = R> + 'b,
F: FnMut(Self::Item) -> R + 'b;
fn select<FVal, FSig, Data, Out>(
self,
fn_val: FVal,
fn_sig: FSig,
data: Data
) -> Out
where FVal: FnOnce(Data, Self::Item) -> Out,
FSig: FnOnce(Data, Self::Signal) -> Out,
Self: Sized;
fn select_spawn<FVal, FSig, Task, Exec>(
self,
fn_val: FVal,
fn_sig: FSig,
executor: &mut Exec
)
where FVal: FnOnce(&mut Exec, Self::Item),
FSig: FnOnce(&mut Exec, Self::Signal) -> Task,
Task: Future<Output = ()> + 'a,
Exec: Executor;
}
Expand description
Abstract over a type that can be a value or a signal of an underlying type.
Required Associated Types§
sourcetype Map<'b: 'a, F: FnMut(Self::Item) -> R + 'b, R: RefSignalOrValue<'b, Item = R> + 'b>: RefSignalOrValue<'b, Item = R> + 'b
type Map<'b: 'a, F: FnMut(Self::Item) -> R + 'b, R: RefSignalOrValue<'b, Item = R> + 'b>: RefSignalOrValue<'b, Item = R> + 'b
The return type for Self::map
.
Map
needs a separate lifetime 'b
so that we can map from Self
to
something with a longer lifetime. For example, mapping &str
to
String
.
Required Methods§
sourcefn map<'b, F, R>(self, callback: F) -> Self::Map<'b, F, R>
fn map<'b, F, R>(self, callback: F) -> Self::Map<'b, F, R>
Map a function over this signal/value to produce a new signal/value.
sourcefn select<FVal, FSig, Data, Out>(
self,
fn_val: FVal,
fn_sig: FSig,
data: Data
) -> Out
fn select<FVal, FSig, Data, Out>( self, fn_val: FVal, fn_sig: FSig, data: Data ) -> Out
Select a function based on whether this is a signal or value.
§Params
fn_val
: The function to call if this is a value.fn_sig
: The function to call if this is a signal.data
: Some data for the function to consume. This is useful if either of the functions needs to consume some data.
sourcefn select_spawn<FVal, FSig, Task, Exec>(
self,
fn_val: FVal,
fn_sig: FSig,
executor: &mut Exec
)
fn select_spawn<FVal, FSig, Task, Exec>( self, fn_val: FVal, fn_sig: FSig, executor: &mut Exec )
Object Safety§
This trait is not object safe.