OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library async.streams.stream_subscription; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 /// Simple delegating wrapper around a [StreamSubscription]. |
| 10 /// |
| 11 /// Subclasses can override individual methods. |
| 12 class DelegatingStreamSubscription<T> implements StreamSubscription<T> { |
| 13 final StreamSubscription _source; |
| 14 |
| 15 DelegatingStreamSubscription(StreamSubscription subscription) |
| 16 : _source = subscription; |
| 17 |
| 18 void onData(void handleData(T data)) { |
| 19 _source.onData(handleData); |
| 20 } |
| 21 |
| 22 void onError(Function handleError) { |
| 23 _source.onError(handleError); |
| 24 } |
| 25 |
| 26 void onDone(void handleDone()) { |
| 27 _source.onDone(handleDone); |
| 28 } |
| 29 |
| 30 void pause([Future resumeFuture]) { |
| 31 _source.pause(resumeFuture); |
| 32 } |
| 33 |
| 34 void resume() { |
| 35 _source.resume(); |
| 36 } |
| 37 |
| 38 Future cancel() { |
| 39 return _source.cancel(); |
| 40 } |
| 41 |
| 42 Future asFuture([futureValue]) { |
| 43 return _source.asFuture(futureValue); |
| 44 } |
| 45 |
| 46 bool get isPaused => _source.isPaused; |
| 47 } |
OLD | NEW |