Struct wasm_react::callback::PersistedCallback
source · [−]pub struct PersistedCallback<T, U = ()>(_);
Expand description
This is a wrapper around a Callback
which can persist through the
lifetime of a component.
Usually, this struct is created by using the
use_callback()
hook.
As with Callback
, this only supports closures with exactly one input
argument and some return value. The underlying Rust closure will be dropped
when all of the following conditions are met:
- All clones have been dropped.
- All clones to the underlying
Callback
have been dropped. - The React component has unmounted.
It can be dropped earlier, e.g. when the underlying Callback
has been
replaced by another and no more clones exist.
Methods from Deref<Target = Callback<T, U>>
sourcepub fn to_closure(&self) -> impl FnMut(T) -> U + 'static
pub fn to_closure(&self) -> impl FnMut(T) -> U + 'static
Returns a Rust closure from the callback.
sourcepub fn premap<V>(&self, f: impl FnMut(V) -> T + 'static) -> Callback<V, U>
pub fn premap<V>(&self, f: impl FnMut(V) -> T + 'static) -> Callback<V, U>
Returns a new Callback
by prepending the given closure to the callback.
sourcepub fn postmap<V>(&self, f: impl FnMut(U) -> V + 'static) -> Callback<T, V>
pub fn postmap<V>(&self, f: impl FnMut(U) -> V + 'static) -> Callback<T, V>
Returns a new Callback
by appending the given closure to the callback.
sourcepub fn as_js(&self) -> Ref<'_, JsValue> where
T: FromWasmAbi,
U: IntoWasmAbi,
pub fn as_js(&self) -> Ref<'_, JsValue> where
T: FromWasmAbi,
U: IntoWasmAbi,
Returns a reference to JsValue
of the callback.
Trait Implementations
sourceimpl<T, U> AsRef<Callback<T, U>> for PersistedCallback<T, U>
impl<T, U> AsRef<Callback<T, U>> for PersistedCallback<T, U>
sourceimpl<T, U> Callable<T, U> for PersistedCallback<T, U>
impl<T, U> Callable<T, U> for PersistedCallback<T, U>
sourceimpl<T, U> Clone for PersistedCallback<T, U>
impl<T, U> Clone for PersistedCallback<T, U>
sourceimpl<T, U> Debug for PersistedCallback<T, U>
impl<T, U> Debug for PersistedCallback<T, U>
sourceimpl<T, U> Deref for PersistedCallback<T, U>
impl<T, U> Deref for PersistedCallback<T, U>
sourceimpl<T, U> From<PersistedCallback<T, U>> for Callback<T, U>
impl<T, U> From<PersistedCallback<T, U>> for Callback<T, U>
sourcefn from(value: PersistedCallback<T, U>) -> Self
fn from(value: PersistedCallback<T, U>) -> Self
Converts to this type from the input type.
sourceimpl<T, U> PartialEq<PersistedCallback<T, U>> for PersistedCallback<T, U>
impl<T, U> PartialEq<PersistedCallback<T, U>> for PersistedCallback<T, U>
impl<T, U> Eq for PersistedCallback<T, U>
impl<T: 'static, U: 'static> Persisted for PersistedCallback<T, U>
Auto Trait Implementations
impl<T, U = ()> !RefUnwindSafe for PersistedCallback<T, U>
impl<T, U = ()> !Send for PersistedCallback<T, U>
impl<T, U = ()> !Sync for PersistedCallback<T, U>
impl<T, U> Unpin for PersistedCallback<T, U>
impl<T, U = ()> !UnwindSafe for PersistedCallback<T, U>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more