#[repr(transparent)]pub struct Signal<S> { /* private fields */ }
Implementations§
source§impl<S> Signal<S>
impl<S> Signal<S>
sourcepub fn update<F, O>(&self, mutator: F)where
F: FnOnce(&mut S) -> O,
O: ShouldRender,
pub fn update<F, O>(&self, mutator: F)where F: FnOnce(&mut S) -> O, O: ShouldRender,
Update the state behind this Signal
.
fn example(count: Signal<i32>) {
// increment count and trigger a render
count.update(|count| *count += 1);
// increment count if less than 10, only render on change
count.update(|count| {
if *count < 10 {
*count += 1;
Then::Render
} else {
Then::Stop
}
})
}
sourcepub fn update_silent<F>(&self, mutator: F)where
F: FnOnce(&mut S),
pub fn update_silent<F>(&self, mutator: F)where F: FnOnce(&mut S),
Same as update
, but it never renders updates.
Trait Implementations§
Auto Trait Implementations§
impl<S> !RefUnwindSafe for Signal<S>
impl<S> !Send for Signal<S>
impl<S> !Sync for Signal<S>
impl<S> Unpin for Signal<S>
impl<S> !UnwindSafe for Signal<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