pub struct Runtime<S, A: Action, E = NoEffect, Routing = Direct, St = Store<S, A, E>>where
St: RuntimeStore<S, A, E>,{ /* private fields */ }Expand description
Runtime helper for store-driven applications.
Implementations§
Source§impl<S, A, E, Routing, St> Runtime<S, A, E, Routing, St>where
S: 'static,
A: Action,
St: RuntimeStore<S, A, E>,
impl<S, A, E, Routing, St> Runtime<S, A, E, Routing, St>where
S: 'static,
A: Action,
St: RuntimeStore<S, A, E>,
Sourcepub fn with_event_bus<Id, Ctx>(
self,
bus: EventBus<S, A, Id, Ctx>,
keybindings: Keybindings<Ctx>,
) -> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>
pub fn with_event_bus<Id, Ctx>( self, bus: EventBus<S, A, Id, Ctx>, keybindings: Keybindings<Ctx>, ) -> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>
Pair this runtime with an EventBus + Keybindings so raw events
are routed through the bus before actions are dispatched.
Source§impl<S, A, E, Id, Ctx, St> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, E>,
impl<S, A, E, Id, Ctx, St> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, E>,
Sourcepub fn keybindings(&self) -> &Keybindings<Ctx>
pub fn keybindings(&self) -> &Keybindings<Ctx>
Access the keybindings.
Sourcepub fn keybindings_mut(&mut self) -> &mut Keybindings<Ctx>
pub fn keybindings_mut(&mut self) -> &mut Keybindings<Ctx>
Access the keybindings mutably.
Source§impl<S, A, Id, Ctx, St> Runtime<S, A, NoEffect, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, NoEffect>,
impl<S, A, Id, Ctx, St> Runtime<S, A, NoEffect, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, NoEffect>,
Sourcepub async fn run<B, FRender, FQuit>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
pub async fn run<B, FRender, FQuit>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
Run the event/action loop until quit, routing raw events through the bus + keybindings.
Sourcepub async fn run_with_hooks<B, FRender, FQuit, FAfter>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
after_render: FAfter,
) -> Result<()>
pub async fn run_with_hooks<B, FRender, FQuit, FAfter>( &mut self, terminal: &mut Terminal<B>, render: FRender, should_quit: FQuit, after_render: FAfter, ) -> Result<()>
Run the event/action loop with a post-render hook invoked after each frame is drawn.
Source§impl<S, A, E, Id, Ctx, St> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, E>,
impl<S, A, E, Id, Ctx, St> Runtime<S, A, E, EventBusRouting<S, A, Id, Ctx>, St>where
S: 'static + EventRoutingState<Id, Ctx>,
A: Action,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
St: RuntimeStore<S, A, E>,
Sourcepub async fn run_with_effects<B, FRender, FQuit, FEffect>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
FEffect: FnMut(E, &mut EffectContext<'_, A>),
pub async fn run_with_effects<B, FRender, FQuit, FEffect>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
FEffect: FnMut(E, &mut EffectContext<'_, A>),
Run the event/action loop until quit, routing raw events through the bus + keybindings and handling emitted effects at the run boundary.
Sourcepub async fn run_with_effect_hooks<B, FRender, FQuit, FEffect, FAfter>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
after_render: FAfter,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
FEffect: FnMut(E, &mut EffectContext<'_, A>),
FAfter: FnMut(&mut EventBus<S, A, Id, Ctx>, &S),
pub async fn run_with_effect_hooks<B, FRender, FQuit, FEffect, FAfter>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
after_render: FAfter,
) -> Result<()>where
B: Backend,
FRender: FnMut(&mut Frame<'_>, Rect, &S, RenderContext, &mut EventContext<Id>),
FQuit: FnMut(&A) -> bool,
FEffect: FnMut(E, &mut EffectContext<'_, A>),
FAfter: FnMut(&mut EventBus<S, A, Id, Ctx>, &S),
Run the event/action loop with effects and a post-render hook invoked after each frame is drawn.
Source§impl<S: 'static, A: Action, E, St: RuntimeStore<S, A, E>> Runtime<S, A, E, Direct, St>
impl<S: 'static, A: Action, E, St: RuntimeStore<S, A, E>> Runtime<S, A, E, Direct, St>
Sourcepub fn from_store(store: St) -> Self
pub fn from_store(store: St) -> Self
Create a runtime from an existing store.
Source§impl<S: 'static, A: Action, E, Routing, St> Runtime<S, A, E, Routing, St>where
St: RuntimeStore<S, A, E>,
impl<S: 'static, A: Action, E, Routing, St> Runtime<S, A, E, Routing, St>where
St: RuntimeStore<S, A, E>,
Sourcepub fn with_event_poller(self, config: PollerConfig) -> Self
pub fn with_event_poller(self, config: PollerConfig) -> Self
Configure event polling behavior.
Sourcepub fn with_dispatch_error_handler<F>(self, handler: F) -> Self
pub fn with_dispatch_error_handler<F>(self, handler: F) -> Self
Configure handling for recoverable dispatch errors.
The handler receives each DispatchError and selects a
DispatchErrorPolicy. Runtimes do not log or store errors by default;
do that inside this closure when needed.
Sourcepub fn subscribe_actions(&self) -> Receiver<String>
pub fn subscribe_actions(&self) -> Receiver<String>
Subscribe to action name broadcasts.
Sourcepub fn action_tx(&self) -> UnboundedSender<A>
pub fn action_tx(&self) -> UnboundedSender<A>
Clone the action sender.
Source§impl<S: 'static, A: Action, St> Runtime<S, A, NoEffect, Direct, St>where
St: RuntimeStore<S, A, NoEffect>,
impl<S: 'static, A: Action, St> Runtime<S, A, NoEffect, Direct, St>where
St: RuntimeStore<S, A, NoEffect>,
Source§impl<S: 'static, A: Action, E, St> Runtime<S, A, E, Direct, St>where
St: RuntimeStore<S, A, E>,
impl<S: 'static, A: Action, E, St> Runtime<S, A, E, Direct, St>where
St: RuntimeStore<S, A, E>,
Sourcepub async fn run_with_effects<B, FRender, FEvent, FQuit, FEffect, R>(
&mut self,
terminal: &mut Terminal<B>,
render: FRender,
map_event: FEvent,
should_quit: FQuit,
handle_effect: FEffect,
) -> Result<()>
pub async fn run_with_effects<B, FRender, FEvent, FQuit, FEffect, R>( &mut self, terminal: &mut Terminal<B>, render: FRender, map_event: FEvent, should_quit: FQuit, handle_effect: FEffect, ) -> Result<()>
Run the event/action loop until quit, handling emitted effects at the run boundary.
Auto Trait Implementations§
impl<S, A, E, Routing, St> Freeze for Runtime<S, A, E, Routing, St>
impl<S, A, E = NoEffect, Routing = Direct, St = Store<S, A, E>> !RefUnwindSafe for Runtime<S, A, E, Routing, St>
impl<S, A, E = NoEffect, Routing = Direct, St = Store<S, A, E>> !Send for Runtime<S, A, E, Routing, St>
impl<S, A, E = NoEffect, Routing = Direct, St = Store<S, A, E>> !Sync for Runtime<S, A, E, Routing, St>
impl<S, A, E, Routing, St> Unpin for Runtime<S, A, E, Routing, St>
impl<S, A, E, Routing, St> UnsafeUnpin for Runtime<S, A, E, Routing, St>where
St: UnsafeUnpin,
Routing: UnsafeUnpin,
impl<S, A, E = NoEffect, Routing = Direct, St = Store<S, A, E>> !UnwindSafe for Runtime<S, A, E, Routing, St>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more