SimpleAsyncComponent

Trait SimpleAsyncComponent 

Source
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(
        init: Self::Init,
        root: Self::Root,
        sender: AsyncComponentSender<Self>,
    ) -> impl Future<Output = AsyncComponentParts<Self>>;

    // Provided methods
    fn init_loading_widgets(_root: Self::Root) -> Option<LoadingWidgets> { ... }
    fn update(
        &mut self,
        message: Self::Input,
        sender: AsyncComponentSender<Self>,
    ) -> impl Future<Output = ()> { ... }
    fn update_cmd(
        &mut self,
        input: &Sender<Self::Input>,
        output: Sender<Self::Output>,
    ) -> impl Future<Output = ()> { ... }
    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 top-level widget of 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( init: Self::Init, root: Self::Root, sender: AsyncComponentSender<Self>, ) -> impl Future<Output = AsyncComponentParts<Self>>

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

Provided Methods§

Source

fn init_loading_widgets(_root: 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( &mut self, message: Self::Input, sender: AsyncComponentSender<Self>, ) -> impl Future<Output = ()>

Processes inputs received by the component.

Source

fn update_cmd( &mut self, input: &Sender<Self::Input>, output: Sender<Self::Output>, ) -> impl Future<Output = ()>

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SimpleAsyncComponent for ()

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

Source§

type Input = ()

Source§

type Output = ()

Source§

type Init = ()

Source§

type Root = ()

Source§

type Widgets = ()

Source§

fn init_root() -> Self::Root

Source§

async fn init( _init: Self::Init, _root: Self::Root, _sender: AsyncComponentSender<Self>, ) -> AsyncComponentParts<Self>

Implementors§