pub struct WritableSetter<T: 'static> { /* private fields */ }Expand description
A writable value whose updates go through a setter callback.
use freya::prelude::*;
fn app() -> impl IntoElement {
let mut value = use_state(String::new);
Input::new(WritableSetter::new(value, move |text| value.set(text)))
}Implementations§
Source§impl<T: 'static> WritableSetter<T>
impl<T: 'static> WritableSetter<T>
Sourcepub fn new(
value: impl IntoReadable<T>,
on_change: impl Into<EventHandler<T>>,
) -> Self
pub fn new( value: impl IntoReadable<T>, on_change: impl Into<EventHandler<T>>, ) -> Self
The callback may transform or reject updates to the readable value.
Sourcepub fn read(&self) -> ReadableRef<T>
pub fn read(&self) -> ReadableRef<T>
Read the value and subscribe to changes.
Sourcepub fn peek(&self) -> ReadableRef<T>
pub fn peek(&self) -> ReadableRef<T>
Read the value without subscribing to changes.
Sourcepub fn set_if_modified(&mut self, value: T)where
T: PartialEq,
pub fn set_if_modified(&mut self, value: T)where
T: PartialEq,
Request an update only if the value differs from the current one.
Trait Implementations§
Source§impl<T: 'static> Clone for WritableSetter<T>
impl<T: 'static> Clone for WritableSetter<T>
Source§impl<T: 'static> From<State<T>> for WritableSetter<T>
impl<T: 'static> From<State<T>> for WritableSetter<T>
Source§impl<T: 'static> From<Writable<T>> for WritableSetter<T>
impl<T: 'static> From<Writable<T>> for WritableSetter<T>
Source§impl<T: 'static> From<WritableSetter<T>> for Readable<T>
impl<T: 'static> From<WritableSetter<T>> for Readable<T>
Source§fn from(value: WritableSetter<T>) -> Self
fn from(value: WritableSetter<T>) -> Self
Converts to this type from the input type.
Source§impl<T: 'static> IntoReadable<T> for WritableSetter<T>
impl<T: 'static> IntoReadable<T> for WritableSetter<T>
fn into_readable(self) -> Readable<T>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for WritableSetter<T>
impl<T> !Send for WritableSetter<T>
impl<T> !Sync for WritableSetter<T>
impl<T> !UnwindSafe for WritableSetter<T>
impl<T> Freeze for WritableSetter<T>
impl<T> Unpin for WritableSetter<T>
impl<T> UnsafeUnpin for WritableSetter<T>
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<T> ComponentProps for T
impl<T> ComponentProps for T
fn changed(&self, other: &(dyn ComponentProps + 'static)) -> bool
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 more