pub struct ContextEventManager { /* private fields */ }Expand description
Context event manager that handles all context-level events.
Implementations§
Source§impl ContextEventManager
impl ContextEventManager
Sourcepub async fn on_page<F, Fut>(&self, handler: F) -> HandlerId
pub async fn on_page<F, Fut>(&self, handler: F) -> HandlerId
Register a handler for new page events.
The handler will be called whenever a new page is created in the context. Returns a handler ID that can be used to remove the handler.
Sourcepub async fn off_page(&self, id: HandlerId) -> bool
pub async fn off_page(&self, id: HandlerId) -> bool
Remove a page event handler by its ID.
Returns true if a handler was removed.
Sourcepub async fn on_page_activated<F, Fut>(&self, handler: F) -> HandlerId
pub async fn on_page_activated<F, Fut>(&self, handler: F) -> HandlerId
Register a handler for page activated events.
The handler will be called when a page becomes the active/foreground tab, including when the user clicks on a tab in the browser UI. Returns a handler ID that can be used to remove the handler.
Sourcepub async fn off_page_activated(&self, id: HandlerId) -> bool
pub async fn off_page_activated(&self, id: HandlerId) -> bool
Remove a page activated event handler by its ID.
Returns true if a handler was removed.
Sourcepub async fn emit_page_activated(&self, page: Page)
pub async fn emit_page_activated(&self, page: Page)
Emit a page activated event to all registered handlers.
Sourcepub async fn on_close<F, Fut>(&self, handler: F) -> HandlerId
pub async fn on_close<F, Fut>(&self, handler: F) -> HandlerId
Register a handler for context close events.
The handler will be called when the context is about to close. Returns a handler ID that can be used to remove the handler.
Sourcepub async fn off_close(&self, id: HandlerId) -> bool
pub async fn off_close(&self, id: HandlerId) -> bool
Remove a close event handler by its ID.
Returns true if a handler was removed.
Sourcepub async fn emit_close(&self)
pub async fn emit_close(&self)
Emit a close event to all registered handlers.