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

    // Required methods
    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;

    // Provided methods
    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§

source

type Input: Debug + 'static

The message type that the component accepts as inputs.

source

type Output: Debug + 'static

The message type that the component provides as outputs.

source

type Init

The parameter used to initialize the component.

source

type Root: Debug + Clone

The widget that was constructed by the component.

source

type Widgets: 'static

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

Required Methods§

source

fn init_root() -> Self::Root

Initializes the root widget

source

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,

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

Provided Methods§

source

fn init_loading_widgets(_root: &mut Self::Root) -> Option<LoadingWidgets>

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.

source

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,

Processes inputs received by the component.

source

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,

Defines how the component should respond to command updates.

source

fn update_view( &self, widgets: &mut Self::Widgets, sender: AsyncComponentSender<Self> )

Updates the view after the model has been updated.

source

fn shutdown( &mut self, widgets: &mut Self::Widgets, output: Sender<Self::Output> )

Last method called before a component is shut down.

This method is guaranteed to be called even when the entire application is shut down.

Implementations on Foreign Types§

source§

impl SimpleAsyncComponent for ()

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

§

type Input = ()

§

type Output = ()

§

type Init = ()

§

type Root = ()

§

type Widgets = ()

source§

fn init_root() -> Self::Root

source§

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,

Implementors§