[][src]Trait savory_core::element::Element

pub trait Element {
    type Message: 'static;
    type Config;
    fn init(
        config: Self::Config,
        orders: &mut impl Orders<Self::Message>
    ) -> Self;
fn update(&mut self, _: Self::Message, _: &mut impl Orders<Self::Message>); }

Trait used to create element and handle element messages and update element state accordingly.

Element messages can be emitted by HTML events or by other elements, handling these messages is done inside the method update, both init function and update method receive orders argument which provide many useful methods to interact with the runtime library Seed, for example we can subscribe to messages of some type, we can send messages to other elemenrs, we can perform async blocks and many more things (see Orders).

Associated Types

type Message: 'static

Element message

type Config

Configuration used to initialize this element

Loading content...

Required methods

fn init(config: Self::Config, orders: &mut impl Orders<Self::Message>) -> Self

Create and initialize the element

Arguments

  • config configuration used to create the element.
  • orders used to interacte with the runtime.

fn update(&mut self, _: Self::Message, _: &mut impl Orders<Self::Message>)

update method that recive Self::Message and update the model state accordingly.

Loading content...

Implementors

Loading content...