Struct EventRevoker
pub struct EventRevoker { /* private fields */ }Expand description
A handle that automatically revokes an event registration when dropped.
Obtained by calling an event-registration method (e.g. Click, Closed).
The registration is revoked when the EventRevoker is dropped.
To keep the event handler alive indefinitely, call forget to prevent
the automatic revocation.
Call into_token to take back the raw token and prevent the automatic
revocation, which is useful for interoperating with code that manages
registration tokens directly.
Implementations§
§impl EventRevoker
impl EventRevoker
pub fn into_token(self) -> i64
pub fn into_token(self) -> i64
Consumes the revoker and returns the raw registration token without revoking the event handler.
After this call the automatic revocation on drop is cancelled. The
caller is responsible for passing the returned token to the
corresponding Remove* method when the handler is no longer needed.
pub fn forget(self)
pub fn forget(self)
Consumes the revoker without revoking the event handler, keeping the handler alive indefinitely.
This is useful for “fire and forget” event registrations where the handler should outlive any particular scope.