LifecycleManager

Struct LifecycleManager 

Source
pub struct LifecycleManager { /* private fields */ }
Expand description

Manager for widget lifecycle hooks.

Implementations§

Source§

impl LifecycleManager

Source

pub fn new() -> Self

Create a new lifecycle manager.

Source

pub fn register( &mut self, widget_id: WidgetId, phases: Vec<LifecyclePhase>, callback: LifecycleCallback, ) -> HookId

Register a lifecycle hook.

Returns a hook ID that can be used to unregister the hook.

Source

pub fn on_mount( &mut self, widget_id: WidgetId, callback: LifecycleCallback, ) -> HookId

Register a mount hook.

Source

pub fn on_unmount( &mut self, widget_id: WidgetId, callback: LifecycleCallback, ) -> HookId

Register an unmount hook.

Source

pub fn on_update( &mut self, widget_id: WidgetId, callback: LifecycleCallback, ) -> HookId

Register an update hook.

Source

pub fn on_focus( &mut self, widget_id: WidgetId, callback: LifecycleCallback, ) -> HookId

Register a focus hook.

Source

pub fn on_blur( &mut self, widget_id: WidgetId, callback: LifecycleCallback, ) -> HookId

Register a blur hook.

Source

pub fn unregister(&mut self, hook_id: HookId) -> bool

Unregister a hook.

Source

pub fn unregister_widget(&mut self, widget_id: WidgetId)

Unregister all hooks for a widget.

Source

pub fn emit(&mut self, widget_id: WidgetId, phase: LifecyclePhase)

Emit a lifecycle event immediately.

Source

pub fn queue(&mut self, widget_id: WidgetId, phase: LifecyclePhase)

Queue a lifecycle event for later dispatch.

Source

pub fn flush(&mut self)

Dispatch all pending events.

Source

pub fn pending_count(&self) -> usize

Get the number of pending events.

Source

pub fn tick(&mut self)

Advance the timestamp.

Source

pub fn timestamp(&self) -> u64

Get the current timestamp.

Source

pub fn hook_count(&self) -> usize

Get the number of registered hooks.

Source

pub fn has_hooks(&self, widget_id: WidgetId) -> bool

Check if a widget has any hooks.

Source

pub fn clear(&mut self)

Clear all hooks and events.

Trait Implementations§

Source§

impl Debug for LifecycleManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LifecycleManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.