pub struct SignalSetter<T, S = SyncStorage>where
T: 'static,{ /* private fields */ }Expand description
A wrapper for any kind of settable reactive signal: a WriteSignal,
RwSignal, or closure that receives a value and sets a signal depending
on it.
This allows you to create APIs that take any kind of SignalSetter<T> as an argument,
rather than adding a generic F: Fn(T). Values can be set with the same
function call or set(), API as other signals.
§Core Trait Implementations
.set()(or calling the setter as a function) sets the signal’s value, and notifies all subscribers that the signal’s value has changed. to subscribe to the signal, and to re-run whenever the value of the signal changes.
§Examples
let (count, set_count) = signal(2);
let set_double_input = SignalSetter::map(move |n| set_count.set(n * 2));
// this function takes any kind of signal setter
fn set_to_4(setter: &SignalSetter<i32>) {
// ✅ calling the signal sets the value
// can be `setter(4)` on nightly
setter.set(4);
}
set_to_4(&set_count.into());
assert_eq!(count.get(), 4);
set_to_4(&set_double_input);
assert_eq!(count.get(), 8);Implementations§
Trait Implementations§
Source§impl<T, S> Clone for SignalSetter<T, S>
impl<T, S> Clone for SignalSetter<T, S>
Source§fn clone(&self) -> SignalSetter<T, S>
fn clone(&self) -> SignalSetter<T, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, S> Debug for SignalSetter<T, S>
impl<T, S> Debug for SignalSetter<T, S>
Source§impl<T, S> Default for SignalSetter<T, S>where
T: Default + 'static,
impl<T, S> Default for SignalSetter<T, S>where
T: Default + 'static,
Source§fn default() -> SignalSetter<T, S>
fn default() -> SignalSetter<T, S>
Returns the “default value” for a type. Read more
Source§impl<T, S> Fn(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature nightly only.
impl<T, S> Fn(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature
nightly only.Source§impl<T, S> FnMut(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature nightly only.
impl<T, S> FnMut(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature
nightly only.Source§impl<T, S> FnOnce(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature nightly only.
impl<T, S> FnOnce(T) for SignalSetter<T, S>where
SignalSetter<T, S>: Set<Value = T>,
Available on crate feature
nightly only.Source§impl<T, S> From<RwSignal<T, S>> for SignalSetter<T, S>
impl<T, S> From<RwSignal<T, S>> for SignalSetter<T, S>
Source§fn from(value: RwSignal<T, S>) -> SignalSetter<T, S>
fn from(value: RwSignal<T, S>) -> SignalSetter<T, S>
Converts to this type from the input type.
Source§impl<T, S> From<WriteSignal<T, S>> for SignalSetter<T, S>
impl<T, S> From<WriteSignal<T, S>> for SignalSetter<T, S>
Source§fn from(value: WriteSignal<T, S>) -> SignalSetter<T, S>
fn from(value: WriteSignal<T, S>) -> SignalSetter<T, S>
Converts to this type from the input type.
Source§impl<T, S> PartialEq for SignalSetter<T, S>
impl<T, S> PartialEq for SignalSetter<T, S>
Source§impl<T, S> Set for SignalSetter<T, S>
impl<T, S> Set for SignalSetter<T, S>
impl<T, S> Copy for SignalSetter<T, S>
impl<T, S> Eq for SignalSetter<T, S>
impl<T, S> StructuralPartialEq for SignalSetter<T, S>where
T: 'static,
Auto Trait Implementations§
impl<T, S> Freeze for SignalSetter<T, S>
impl<T, S> RefUnwindSafe for SignalSetter<T, S>
impl<T, S> Send for SignalSetter<T, S>
impl<T, S> Sync for SignalSetter<T, S>
impl<T, S> Unpin for SignalSetter<T, S>
impl<T, S> UnsafeUnpin for SignalSetter<T, S>
impl<T, S> UnwindSafe for SignalSetter<T, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Func, T, P> ComponentConstructor<P, T> for Funcwhere
Func: FnOnce(P) -> T,
P: PropsOrNoPropsBuilder,
impl<Func, T, P> ComponentConstructor<P, T> for Funcwhere
Func: FnOnce(P) -> T,
P: PropsOrNoPropsBuilder,
Source§impl<Func, T> EffectFunction<T, SingleParam> for Func
impl<Func, T> EffectFunction<T, SingleParam> for Func
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<F> ErrorSink for Fwhere
F: FnMut(ParseError),
impl<F> ErrorSink for Fwhere
F: FnMut(ParseError),
fn report_error(&mut self, error: ParseError)
Source§impl<F, E> EventCallback<E> for Fwhere
F: FnMut(E) + 'static,
impl<F, E> EventCallback<E> for Fwhere
F: FnMut(E) + 'static,
Source§impl<F> EventReceiver for F
impl<F> EventReceiver for F
fn std_table_open(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn std_table_close(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn array_table_open(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn array_table_close(&mut self, span: Span, _error: &mut dyn ErrorSink)
Source§fn inline_table_open(&mut self, span: Span, _error: &mut dyn ErrorSink) -> bool
fn inline_table_open(&mut self, span: Span, _error: &mut dyn ErrorSink) -> bool
Returns if entering the inline table is allowed
fn inline_table_close(&mut self, span: Span, _error: &mut dyn ErrorSink)
Source§fn array_open(&mut self, span: Span, _error: &mut dyn ErrorSink) -> bool
fn array_open(&mut self, span: Span, _error: &mut dyn ErrorSink) -> bool
Returns if entering the array is allowed
fn array_close(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn simple_key( &mut self, span: Span, encoding: Option<Encoding>, _error: &mut dyn ErrorSink, )
fn key_sep(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn key_val_sep(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn scalar( &mut self, span: Span, encoding: Option<Encoding>, _error: &mut dyn ErrorSink, )
fn value_sep(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn whitespace(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn comment(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn newline(&mut self, span: Span, _error: &mut dyn ErrorSink)
fn error(&mut self, span: Span, _error: &mut dyn ErrorSink)
Source§impl<F> IntoDirective<(Element,), ()> for F
impl<F> IntoDirective<(Element,), ()> for F
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<I, O, F> IntoReactiveValue<Callback<I, O>, __IntoReactiveValueMarkerCallbackSingleParam> for F
impl<I, O, F> IntoReactiveValue<Callback<I, O>, __IntoReactiveValueMarkerCallbackSingleParam> for F
Source§fn into_reactive_value(self) -> Callback<I, O>
fn into_reactive_value(self) -> Callback<I, O>
Converts
self into a T.Source§impl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
impl<T, I> IntoReactiveValue<T, __IntoReactiveValueMarkerBaseCase> for Iwhere
I: Into<T>,
Source§fn into_reactive_value(self) -> T
fn into_reactive_value(self) -> T
Converts
self into a T.Source§impl<I, O, F> IntoReactiveValue<UnsyncCallback<I, O>, __IntoReactiveValueMarkerCallbackSingleParam> for Fwhere
F: Fn(I) -> O + 'static,
impl<I, O, F> IntoReactiveValue<UnsyncCallback<I, O>, __IntoReactiveValueMarkerCallbackSingleParam> for Fwhere
F: Fn(I) -> O + 'static,
Source§fn into_reactive_value(self) -> UnsyncCallback<I, O>
fn into_reactive_value(self) -> UnsyncCallback<I, O>
Converts
self into a T.Source§impl<F, T, S> IntoSignalSetter<T, S> for F
impl<F, T, S> IntoSignalSetter<T, S> for F
Source§fn into_signal_setter(self) -> SignalSetter<T, S>
fn into_signal_setter(self) -> SignalSetter<T, S>
Consumes
self, returning SignalSetter<T>.Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.