CompositeSubscription class
Acts as a container for multiple subscriptions that can be canceled at once e.g. view subscriptions in Flutter that need to be canceled on view disposal
Can be cleared or disposed. When disposed, cannot be used again.
Example
// init your subscriptions composite.add(stream1.listen(listener1)) ..add(stream2.listen(listener1)) ..add(stream3.listen(listener1));
// clear them all at once composite.clear();
- Implemented types
-
- StreamSubscription<
Never>
- StreamSubscription<
Constructors
Properties
- allPaused → bool
-
Whether all managed StreamSubscriptions are currently paused.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Checks if this composite is disposed. If it is, the composite can't be used again
and will throw an error if you try to add more subscriptions to it.
no setter
- isEmpty → bool
-
Checks if there currently are no StreamSubscriptions added
no setter
- isNotEmpty → bool
-
Checks if there currently are StreamSubscriptions added
no setter
- isPaused → bool
-
Whether the StreamSubscription is currently paused.
no setteroverride
- length → int
-
Returns the total amount of currently added StreamSubscriptions
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add<
T> (StreamSubscription< T> subscription) → StreamSubscription<T> - Adds new subscription to this composite.
-
asFuture<
E> ([E? futureValue]) → Never -
Returns a future that handles the onDone and onError callbacks.
override
-
cancel(
) → Future< void> -
Cancels this subscription.
override
-
clear(
) → Future< void> ? - Cancels all subscriptions added to this composite. Clears subscriptions collection.
-
dispose(
) → Future< void> ? - Cancels all subscriptions added to this composite. Disposes this.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onData(
void handleData(Never data)?) → Never -
Replaces the data event handler of this subscription.
override
-
onDone(
void handleDone()?) → Never -
Replaces the done event handler of this subscription.
override
-
onError(
Function? handleError) → Never -
Replaces the error event handler of this subscription.
override
-
pause(
[Future< void> ? resumeSignal]) → void -
Requests that the stream pauses events until further notice.
override
-
pauseAll(
[Future< void> ? resumeSignal]) → void - Pauses all subscriptions added to this composite.
-
remove(
StreamSubscription subscription, {bool shouldCancel = true}) → Future< void> ? - Remove the subscription from this composite and cancel it if it has been removed.
-
resume(
) → void -
Resumes after a pause.
override
-
resumeAll(
) → void - Resumes all subscriptions added to this composite.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited