SoloSubscriptions class final
A group of subscriptions cancelled together, for a screen or an object that listens to several things at once.
The group holds what it would cancel and nothing else: a member cancelled on its own is forgotten, so a long-lived group — a screen that resubscribes on every update, a service that listens to whatever it is handed — does not grow one dead entry per subscription that ended by itself.
final _listening = SoloSubscriptions();
void _start() {
controller.listen(_onState).addTo(_listening);
canSave.listen(_onCanSave).addTo(_listening);
}
@override
void dispose() {
_listening.cancel();
super.dispose();
}
Constructors
- SoloSubscriptions()
- Creates an empty group.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isCancelled → bool
-
Whether cancel has been called.
no setter
- length → int
-
How many live subscriptions the group holds.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
SoloSubscription subscription) → void -
Takes
subscriptioninto the group. -
cancel(
) → void - Cancels every subscription in the group and empties it; calling it again does nothing.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited