disposebag library

Helper disposing Streams and closing Sinks

Author: Petrus Nguyễn Thái Học

Usage example

final controller = StreamController<int>();

final bag = DisposeBag([
    controller,
    controller.stream.listen(controller1.add)
]);
// Dispose all stream subscriptions, close all stream controllers
await bag.dispose();

print("Bag disposed. It's all good");

Classes

DisposeBag
Class that helps closing sinks and canceling stream subscriptions

Extensions

SinkDisposedByExtension
disposedBy extension method for Sink
SinkIterableDisposedByExtension
disposedBy extension method for Iterable of Sinks
StreamSubscriptionDisposedByExtension
disposedBy extension method for StreamSubscription
StreamSubscriptionIterableDisposedByExtension
disposedBy extension method for Iterable of StreamSubscriptions

Properties

defaultLogger Logger
Default DisposeBag logger
final

Enums

BagResult
Represents the result of disposing or clearing.

Typedefs

Logger(BagResult result, Set resources, [Object error, StackTrace stackTrace]) → void
Logs the result of disposing or clearing. By default, prints the result to the console.