Trait rxrust::subscription::Subscription
source · pub trait Subscription {
// Required method
fn unsubscribe(self);
// Provided methods
fn is_closed(&self) -> bool { ... }
fn unsubscribe_when_dropped(self) -> SubscriptionGuard<Self>
where Self: Sized { ... }
}Expand description
Subscription returns from Observable.subscribe(Subscriber) to allow
unsubscribing.
Required Methods§
sourcefn unsubscribe(self)
fn unsubscribe(self)
This allows deregistering an stream before it has finished receiving all events (i.e. before onCompleted is called).
Provided Methods§
sourcefn unsubscribe_when_dropped(self) -> SubscriptionGuard<Self>where
Self: Sized,
fn unsubscribe_when_dropped(self) -> SubscriptionGuard<Self>where Self: Sized,
Activates “RAII” behavior for this subscription. That means
unsubscribe() will be called automatically as soon as the returned
value goes out of scope.
Attention: If you don’t assign the return value to a variable,
unsubscribe() is called immediately, which is probably not what you
want!