MvuRuntime

Struct MvuRuntime 

Source
pub struct MvuRuntime<Event: Send, Model: Clone + Send, Props> { /* private fields */ }
Expand description

The MVU runtime that orchestrates the event loop.

This is the core of the framework. It:

  1. Initializes the Model and initial Effects via MvuLogic::init
  2. Processes events through MvuLogic::update
  3. Reduces the Model to Props via MvuLogic::view
  4. Delivers Props to the Renderer for rendering

The runtime creates a single Emitter that automatically processes events when Emitter::emit is called, regardless of which thread it’s called from. Events are processed synchronously in a thread-safe manner.

For testing with manual control, use [TestMvuRuntime] with a [crate::TestRenderer].

See the crate-level documentation for a complete example.

Implementations§

Source§

impl<Event: Send + 'static, Model: Clone + Send + 'static, Props: 'static> MvuRuntime<Event, Model, Props>

Source

pub fn new( init_model: Model, logic: Box<dyn MvuLogic<Event, Model, Props> + Send>, renderer: Box<dyn Renderer<Props> + Send>, spawner: Spawner, ) -> Self

Create a new runtime.

The runtime will not be started until MvuRuntime::run is called.

§Arguments
  • init_model - The initial state
  • logic - Application logic implementing MvuLogic
  • renderer - Platform rendering implementation for rendering Props
  • spawner - Function to spawn async effects on your chosen runtime
Source

pub fn run(self)

Initialize the runtime loop.

  • Uses the MvuLogic::init function to create and enqueue initial side effects.
  • Reduces the initial Model provided at construction to Props via MvuLogic::view.
  • Renders the initial Props.

Auto Trait Implementations§

§

impl<Event, Model, Props> Freeze for MvuRuntime<Event, Model, Props>

§

impl<Event, Model, Props> !RefUnwindSafe for MvuRuntime<Event, Model, Props>

§

impl<Event, Model, Props> Send for MvuRuntime<Event, Model, Props>

§

impl<Event, Model, Props> !Sync for MvuRuntime<Event, Model, Props>

§

impl<Event, Model, Props> Unpin for MvuRuntime<Event, Model, Props>

§

impl<Event, Model, Props> !UnwindSafe for MvuRuntime<Event, Model, Props>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.