doOnCancel method

Stream<T> doOnCancel (
  1. void onCancel(
      )
    )

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

    Example

    final subscription = TimerStream(1, Duration(minutes: 1))
      .doOnCancel(() => print('hi'));
      .listen(null);
    
    subscription.cancel(); // prints 'hi'
    

    Implementation

    Stream<T> doOnCancel(void Function() onCancel) =>
        transform(DoStreamTransformer<T>(onCancel: onCancel));