doOnCancel method

Observable<T> doOnCancel (void onCancel())

Invokes the given callback function when the stream subscription is cancelled. Often called doOnUnsubscribe or doOnDispose in other implementations.

Example

final subscription = new Observable.timer(1, new Duration(minutes: 1))
  .doOnCancel(() => print("hi"));
  .listen(null);

subscription.cancel(); // prints "hi"

Implementation

Observable<T> doOnCancel(void onCancel()) =>
    transform(new DoStreamTransformer<T>(onCancel: onCancel));