pub trait SimpleAsyncComponent: Sized + 'static {
    type Input: Debug + 'static;
    type Output: Debug + 'static;
    type Init;
    type Root: Debug + Clone;
    type Widgets: 'static;

    fn init_root() -> Self::Root;
    fn init<'async_trait>(
        init: Self::Init,
        root: Self::Root,
        sender: AsyncComponentSender<Self>
    ) -> Pin<Box<dyn Future<Output = AsyncComponentParts<Self>> + 'async_trait>>
    where
        Self: 'async_trait
; fn init_loading_widgets(_root: &mut Self::Root) -> Option<LoadingWidgets> { ... } fn update<'life0, 'async_trait>(
        &'life0 mut self,
        message: Self::Input,
        sender: AsyncComponentSender<Self>
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } fn update_cmd<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        input: &'life1 Sender<Self::Input>,
        output: Sender<Self::Output>
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
, { ... } fn update_view(
        &self,
        widgets: &mut Self::Widgets,
        sender: AsyncComponentSender<Self>
    ) { ... } fn shutdown(
        &mut self,
        widgets: &mut Self::Widgets,
        output: Sender<Self::Output>
    ) { ... } }
Expand description

Asynchronous variant of SimpleComponent.

Required Associated Types§

The message type that the component accepts as inputs.

The message type that the component provides as outputs.

The parameter used to initialize the component.

The widget that was constructed by the component.

The type that’s used for storing widgets created for this component.

Required Methods§

Initializes the root widget

Creates the initial model and view, docking it into the component.

Provided Methods§

Allows you to initialize the root widget with a temporary value as a placeholder until the init() future completes.

This method does nothing by default.

Examples found in repository?
src/component/async/traits.rs (line 223)
222
223
224
    fn init_loading_widgets(root: &mut Self::Root) -> Option<LoadingWidgets> {
        C::init_loading_widgets(root)
    }

Processes inputs received by the component.

Examples found in repository?
src/component/async/traits.rs (line 240)
234
235
236
237
238
239
240
241
    async fn update(
        &mut self,
        message: Self::Input,
        sender: AsyncComponentSender<Self>,
        _root: &Self::Root,
    ) {
        C::update(self, message, sender).await;
    }

Defines how the component should respond to command updates.

Updates the view after the model has been updated.

Examples found in repository?
src/component/async/traits.rs (line 244)
243
244
245
    fn update_view(&self, widgets: &mut Self::Widgets, sender: AsyncComponentSender<Self>) {
        C::update_view(self, widgets, sender);
    }

Last method called before a component is shut down.

Examples found in repository?
src/component/async/traits.rs (line 248)
247
248
249
    fn shutdown(&mut self, widgets: &mut Self::Widgets, output: Sender<Self::Output>) {
        self.shutdown(widgets, output);
    }

Implementations on Foreign Types§

An empty, non-interactive component as a placeholder for tests.

Implementors§