pub struct ComponentEvent<'d, C: 'static, D> { /* private fields */ }Expand description
A helper type that contains the event target and the event detail.
It implements Deref<ComponentRc<C>> so that any associated function in ComponentRc<C> can be visited.
Implementations§
Source§impl<'d, C: 'static, D> ComponentEvent<'d, C, D>
impl<'d, C: 'static, D> ComponentEvent<'d, C, D>
Sourcepub fn new(rc: ComponentRc<C>, detail: &'d mut D) -> Self
pub fn new(rc: ComponentRc<C>, detail: &'d mut D) -> Self
Create with event target and detail.
Sourcepub fn rc(&self) -> ComponentRc<C>
pub fn rc(&self) -> ComponentRc<C>
Get the target component.
Sourcepub fn clone_detail(&self) -> Dwhere
D: Clone,
pub fn clone_detail(&self) -> Dwhere
D: Clone,
Clone the event detail.
Sourcepub fn detail_mut(&mut self) -> &mut D
pub fn detail_mut(&mut self) -> &mut D
Get the mutable reference of the event detail.
Methods from Deref<Target = ComponentRc<C>>§
Sourcepub fn task<R: 'static>(&self, f: impl 'static + FnOnce(&mut C) -> R)
pub fn task<R: 'static>(&self, f: impl 'static + FnOnce(&mut C) -> R)
Schedule an update in another task, getting the component mutable reference.
The f will be called asynchronously.
The template is always updated after f being called.
Panics if any error occurred during update.
Sourcepub fn task_with<R: 'static>(
&self,
f: impl 'static + FnOnce(&mut C, &mut ComponentMutCtx) -> R,
)
pub fn task_with<R: 'static>( &self, f: impl 'static + FnOnce(&mut C, &mut ComponentMutCtx) -> R, )
Schedule an update in another task, getting the component mutable reference.
The f will be called asynchronously.
If the template is needed to be updated, ComponentMutCtx::need_update should be called during f execution.
Panics if any error occurred during update.
Sourcepub async fn update<R: 'static>(
&self,
f: impl 'static + FnOnce(&mut C) -> R,
) -> Result<R, Error>
pub async fn update<R: 'static>( &self, f: impl 'static + FnOnce(&mut C) -> R, ) -> Result<R, Error>
Schedule an update, getting the component mutable reference.
The f will be called asynchronously.
The template is always updated after f being called.
Sourcepub async fn update_with<R: 'static>(
&self,
f: impl 'static + FnOnce(&mut C, &mut ComponentMutCtx) -> R,
) -> Result<R, Error>
pub async fn update_with<R: 'static>( &self, f: impl 'static + FnOnce(&mut C, &mut ComponentMutCtx) -> R, ) -> Result<R, Error>
Schedule a visiting task, getting the component mutable reference.
The f will be called asynchronously.
If the template is needed to be updated, ComponentMutCtx::need_update should be called during f execution.