pub struct EffectRuntime<S, A: Action, E, St: EffectStoreLike<S, A, E> = EffectStore<S, A, E>> { /* private fields */ }Expand description
Runtime helper for effect-based stores.
Implementations§
Source§impl<S: 'static, A: Action, E> EffectRuntime<S, A, E, EffectStore<S, A, E>>
impl<S: 'static, A: Action, E> EffectRuntime<S, A, E, EffectStore<S, A, E>>
Sourcepub fn new(state: S, reducer: EffectReducer<S, A, E>) -> Self
pub fn new(state: S, reducer: EffectReducer<S, A, E>) -> Self
Create a runtime from state + effect reducer.
Source§impl<S: 'static, A: Action, E, St: EffectStoreLike<S, A, E>> EffectRuntime<S, A, E, St>
impl<S: 'static, A: Action, E, St: EffectStoreLike<S, A, E>> EffectRuntime<S, A, E, St>
Sourcepub fn from_store(store: St) -> Self
pub fn from_store(store: St) -> Self
Create a runtime from an existing effect store.
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.
Returns a receiver that will receive action names (from action.name())
whenever an action is dispatched. Useful for replay await functionality.
Sourcepub fn action_tx(&self) -> UnboundedSender<A>
pub fn action_tx(&self) -> UnboundedSender<A>
Clone the action sender.
Sourcepub async fn run<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<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.
Sourcepub async fn run_with_bus<B, FRender, FQuit, FEffect, Id, Ctx>(
&mut self,
terminal: &mut Terminal<B>,
bus: &mut EventBus<S, A, Id, Ctx>,
keybindings: &Keybindings<Ctx>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
) -> Result<()>where
B: Backend,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
S: EventRoutingState<Id, Ctx>,
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_bus<B, FRender, FQuit, FEffect, Id, Ctx>(
&mut self,
terminal: &mut Terminal<B>,
bus: &mut EventBus<S, A, Id, Ctx>,
keybindings: &Keybindings<Ctx>,
render: FRender,
should_quit: FQuit,
handle_effect: FEffect,
) -> Result<()>where
B: Backend,
Id: ComponentId + 'static,
Ctx: BindingContext + 'static,
S: EventRoutingState<Id, Ctx>,
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 using an EventBus for routing.
Auto Trait Implementations§
impl<S, A, E, St> Freeze for EffectRuntime<S, A, E, St>where
St: Freeze,
impl<S, A, E, St = EffectStore<S, A, E>> !RefUnwindSafe for EffectRuntime<S, A, E, St>
impl<S, A, E, St = EffectStore<S, A, E>> !Send for EffectRuntime<S, A, E, St>
impl<S, A, E, St = EffectStore<S, A, E>> !Sync for EffectRuntime<S, A, E, St>
impl<S, A, E, St> Unpin for EffectRuntime<S, A, E, St>
impl<S, A, E, St> UnsafeUnpin for EffectRuntime<S, A, E, St>where
St: UnsafeUnpin,
impl<S, A, E, St = EffectStore<S, A, E>> !UnwindSafe for EffectRuntime<S, A, E, 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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