IInteraction
trait · ferroui-reactiveui · v0.5.0
trait IInteraction<I, O>
An interaction between collaborating parts of an application (IInteraction<TInput, TOutput>):
one part asks a question (the input), and a handler that another part registered answers it
(the output). Typically a view model asks its view for a confirmation.
Deviation (DEVIATIONS.md, ReactiveUI): the handlers are shared closures, so that the trait can
be a trait object; the asynchronous handler gives a task, the Shared of a
Result<(), ObservableError>, and the observable-based one an
observable of () (upstream's TDontCare: its values are ignored). Interaction
itself has generic forms that take any closure.
Members
register_handler
fn register_handler(self: &Self, handler: Rc<dyn Fn(Rc<dyn IInteractionContext<I, O>>) -> ()>) -> Rc<dyn IDisposable>
Registers a synchronous handler; disposing the result unregisters it
(RegisterHandler(Action<IInteractionContext<TInput, TOutput>>)).
register_handler_task
fn register_handler_task(self: &Self, handler: Rc<dyn Fn(Rc<dyn IInteractionContext<I, O>>) -> Shared<Result<(), ObservableError>>>) -> Rc<dyn IDisposable>
Registers a task-based asynchronous handler; disposing the result unregisters it
(RegisterHandler(Func<IInteractionContext<TInput, TOutput>, Task>)).
register_handler_observable
fn register_handler_observable(self: &Self, handler: Rc<dyn Fn(Rc<dyn IInteractionContext<I, O>>) -> Rc<dyn IObservable<()>>>) -> Rc<dyn IDisposable>
Registers an observable-based asynchronous handler, which finishes when its observable ends
(RegisterHandler<TDontCare>(Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>>)).
handle
fn handle(self: &Self, input: I) -> Rc<dyn IObservable<O>>
Asks the question: a cold observable that runs the handlers, latest registered first, until
one sets an output, each time it is subscribed, then notifies the output and ends. It fails
with UnhandledInteractionError when no handler
sets one (Handle(TInput)).
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.