FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    SubscribeGuard

    trait · ferroui-system · v0.5.0

    trait SubscribeGuard<T>
    

    Subscribes and returns the Subscription guard instead of the handle (C3b of #423, docs/idiomatic-rust-disposal.md, step D5).

    IObservable::subscribe keeps returning the Rc<dyn IDisposable> of the Rx contract, which the operators compose and which keeps the subscription alive when it is dropped. An owner that keeps a subscription only to end it later subscribes with subscribe_guard and holds the guard: dropping it unsubscribes, once, and Subscription::detach gives the handle back where the subscription is meant to last as long as its source.

    The trait is implemented for every observable, sized or not, so it applies to a concrete observable, to dyn IObservable<T> and, through deref, to Rc<dyn IObservable<T>>.

    View source

    Members

    subscribe_guard

    fn subscribe_guard(self: &Self, observer: Rc<dyn IObserver<T>>) -> Subscription
    

    Subscribes observer; dropping the returned guard unsubscribes it.

    Source

    Trait implementations

    Availability

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