pub struct ListenHandle {
pub closure: Option<Closure<dyn Fn(JsValue)>>,
/* private fields */
}target_family="wasm" and crate feature event only.Expand description
Handle which holds the function to detach the listener and the correlated callback
Fields§
§closure: Option<Closure<dyn Fn(JsValue)>>The callback which is invoked for the registered event
The callback will get detached, when the handle is dropped. Alternatively it can
also be given to the js runtime (see Closure into_js_value/forget). This isn’t
recommended because this will leak memory by default.
Implementations§
Source§impl ListenHandle
impl ListenHandle
Sourcepub async fn register<T>(
event: &'static str,
callback: impl Fn(T) + 'static,
) -> ListenResultwhere
T: DeserializeOwned,
pub async fn register<T>(
event: &'static str,
callback: impl Fn(T) + 'static,
) -> ListenResultwhere
T: DeserializeOwned,
Registers a given event with the correlation callback and returns a ListenResult
Sourcepub fn detach_listen(&mut self)
pub fn detach_listen(&mut self)
Detaches the callback from the registered event
Sourcepub fn use_register<P, F: Field<P>>(
initial_value: Option<F::Type>,
) -> ReadSignal<<F as Field<P>>::Type, LocalStorage>where
P: Parent,
Available on crate feature leptos only.
pub fn use_register<P, F: Field<P>>(
initial_value: Option<F::Type>,
) -> ReadSignal<<F as Field<P>>::Type, LocalStorage>where
P: Parent,
leptos only.Registers a given event and binds a returned signal to these event changes
Providing None will unwrap into the default value. When feature initial_value
is enabled None will try to get the value from tauri.
Internally it stores a created ListenHandle for event in a leptos::prelude::RwSignal to hold it in
scope, while it is used in a leptos component
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ListenHandle
impl !RefUnwindSafe for ListenHandle
impl !Send for ListenHandle
impl !Sync for ListenHandle
impl Unpin for ListenHandle
impl !UnwindSafe for ListenHandle
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
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>
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>
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