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.delegating_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 /// Create delegating subscription forwarding calls to [sourceSubscription]. | |
16 DelegatingStreamSubscription(StreamSubscription sourceSubscription) | |
17 : _source = sourceSubscription; | |
18 | |
19 void onData(void handleData(T data)) { | |
20 _source.onData(handleData); | |
21 } | |
22 | |
23 void onError(Function handleError) { | |
24 _source.onError(handleError); | |
25 } | |
26 | |
27 void onDone(void handleDone()) { | |
28 _source.onDone(handleDone); | |
29 } | |
30 | |
31 void pause([Future resumeFuture]) { | |
32 _source.pause(resumeFuture); | |
33 } | |
34 | |
35 void resume() { | |
36 _source.resume(); | |
37 } | |
38 | |
39 Future cancel() => _source.cancel(); | |
40 | |
41 Future asFuture([futureValue]) => _source.asFuture(futureValue); | |
42 | |
43 bool get isPaused => _source.isPaused; | |
44 } | |
OLD | NEW |