FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    AsyncSubject

    struct · ferroui-reactive · v0.5.0

    struct AsyncSubject<T>
    

    A subject that keeps the last value and hands it, with the end, to every observer once the sequence has ended (AsyncSubject<T>).

    View source

    Members

    new

    fn new() -> Rc<Self>
    

    Source

    is_completed

    fn is_completed(self: &Self) -> bool
    

    Whether the subject has ended (IsCompleted).

    Source

    get_result

    fn get_result(self: &Self) -> Result<Option<T>, ObservableError>
    

    The last value of an ended subject (GetResult): the error when it ended with one, None when it ended without a value (upstream throws InvalidOperationException). Panics when the subject has not ended, where upstream blocks until it does (a wait on the only thread would never end).

    Source

    get_awaiter

    fn get_awaiter(self: &Self) -> Shared<Result<T, ObservableError>>
    

    The awaiter of the subject (GetAwaiter): a task, the Shared of a result, that ends when the subject ends, with its last value, with its error (a cancellation's included), or with SequenceError::NoElements when it ended without a value (GetResult's InvalidOperationException). async code awaits its flatten().

    Upstream's subject is its own awaiter; its members are those of the task: IsCompleted is Shared::is_finished, OnCompleted(Action) is Shared::on_finished and GetResult is Shared::result once the task has ended.

    The awaiter captures the current SynchronizationContext of the thread, as upstream's AwaitObserver does, which is its current schedule (ferroui_system::task::current_schedule; in a dispatcher job the dispatcher at the priority of the job): when there is one, the end of the subject is posted to it (with schedule_local), and the task ends, running its continuations, when the schedule runs that work; without one, the task ends where the subject does.

    Deviation (DEVIATIONS.md, Reactive): upstream posts only the continuation of OnCompleted and its IsCompleted is true as soon as the subject has ended; the task of the port ends when the posted work runs, so its is_finished is false until then. The context is captured when the awaiter is made, where upstream captures it when the continuation is given (OnCompleted).

    Panics

    When the subject is disposed (ObjectDisposedException).

    Source

    as_observable

    fn as_observable(self: &Rc<Self>) -> Rc<dyn IObservable<T>>
    

    Source

    as_observer

    fn as_observer(self: &Rc<Self>) -> Rc<dyn IObserver<T>>
    

    Source

    Trait implementations

    Availability

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