stream_disposable 0.1.0
stream_disposable: ^0.1.0

Flutter Android iOS web

Package to help disposing Stream Subscriptions and Sink objects

Build Status

Stream Disposable #

Package to help disposing Streams and Sinks.

Simple Usage #

Instantiate a disposable with

 var disposable = StreamDisposable()

Add StreamSubscriptions or Sinks to it by calling add

   var streamToDispose = Stream.fromIterable([1, 2, 3]);
   disposable.add(streamToDispose.listen(print))

In the Stateful's Widget dispose method or equivalent, we can call

 disposable.dispose(className: this.runtimeType.toString())

To safely dispose every subscription.

Available Methods #

  • void add Adds a Sink or a StreamSusbcription to the disposable. Throws an Error if another type of object is added or if the disposable has already been disposed.

  • Future<void> didDispose Future that completes when the StreamDisposable is disposed.

  • bool isDisposed Boolean value to check if the disposable has been disposed.

  • Future<void> dispose Dispose the current Sink and StreamSusbcription that were addded to this instance. Throws an error if a dispose action is in process or if the disposable has been disposed already.

1
likes
110
pub points
87%
popularity

Publisher

gpalma.pt

Package to help disposing Stream Subscriptions and Sink objects

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

flutter

More

Packages that depend on stream_disposable