FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Interaction

    struct · ferroui-reactiveui · v0.5.0

    struct Interaction<I, O>
    

    An interaction between collaborating parts of an application (Interaction<TInput, TOutput>). It is a shared handle: clones are the same interaction.

    The handlers run in the reverse order of their registration: the handler registered last has the first chance to handle a question. A handler need not handle it, and leaves it to the next one; handle fails with an UnhandledInteractionError when no handler set an output.

    Deviation (DEVIATIONS.md, ReactiveUI): upstream's virtual members (Handle, GenerateContext) and protected GetHandlers serve subclasses; Rust has none, so handle and get_handlers are public and the context is always an InteractionContext. A handler that throws upstream faults the question; here a handler that panics does, its panic caught as a PanicError.

    View source

    Members

    new

    fn new() -> Self
    

    An interaction that invokes its handlers on the thread that asks (Interaction()).

    Source

    with_scheduler

    fn with_scheduler(handler_scheduler: Option<Rc<dyn IScheduler>>) -> Self
    

    An interaction that invokes each handler on handler_scheduler, such as the main thread's; None invokes them on the thread that asks (Interaction(IScheduler?)).

    Source

    register_handler

    fn register_handler(self: &Self, handler: impl Fn(Rc<dyn IInteractionContext<I, O>>) -> () + 'static) -> Rc<dyn IDisposable>
    

    Registers a synchronous handler; disposing the result unregisters it (RegisterHandler(Action<IInteractionContext<TInput, TOutput>>)).

    Source

    register_handler_task

    fn register_handler_task<Fut: Future<Output = Result<(), ObservableError>> + 'static>(self: &Self, handler: impl Fn(Rc<dyn IInteractionContext<I, O>>) -> Fut + 'static) -> Rc<dyn IDisposable>
    

    Registers an asynchronous handler: the future it gives runs as a task of the thread, and the next handler runs when it has ended (RegisterHandler(Func<IInteractionContext<TInput, TOutput>, Task>)). The flatten() of a Shared or of a oneshot receiver is such a future.

    Source

    register_handler_observable

    fn register_handler_observable<D: 'static>(self: &Self, handler: impl Fn(Rc<dyn IInteractionContext<I, O>>) -> Rc<dyn IObservable<D>> + 'static) -> Rc<dyn IDisposable>
    

    Registers a handler that finishes when the observable it gives ends; its values are ignored, and its error faults the question (RegisterHandler<TDontCare>(Func<IInteractionContext<TInput, TOutput>, IObservable<TDontCare>>)).

    Source

    handle

    fn handle(self: &Self, input: I) -> Shared<Result<O, ObservableError>>
    

    Runs the handlers, latest registered first, until one sets an output, and gives a task of that output, the Shared of its result (flatten() is a future of it); the task fails with an UnhandledInteractionError when no handler set one (Handle(TInput)).

    Source

    when_handled

    fn when_handled(self: &Self, input: I) -> Rc<dyn IObservable<O>>
    

    Asks the question as an observable: each subscription runs handle once, then notifies the output and ends, or fails with an UnhandledInteractionError (WhenHandled(TInput)). Disposing the subscription drops the output; a handler that is running still finishes.

    Source

    get_handlers

    fn get_handlers(self: &Self) -> Vec<InteractionHandler<I, O>>
    

    A copy of the registered handlers, earliest first (GetHandlers()).

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • Clone
    • PartialEq
    • Debug
    • Default
    • IInteraction<I, O>
    • InteractionValue

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.