OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library unittest.stream_channel; | 5 library test.stream_channel; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 /// An abstract class representing a two-way communication channel. | 9 /// An abstract class representing a two-way communication channel. |
10 /// | 10 /// |
11 /// Subclasses can mix in [StreamChannelMixin] to get default implementations of | 11 /// Subclasses can mix in [StreamChannelMixin] to get default implementations of |
12 /// the various instance methods. | 12 /// the various instance methods. |
13 abstract class StreamChannel<T> { | 13 abstract class StreamChannel<T> { |
14 /// The stream that emits values from the other endpoint. | 14 /// The stream that emits values from the other endpoint. |
15 Stream<T> get stream; | 15 Stream<T> get stream; |
(...skipping 23 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 /// A mixin that implements the instance methods of [StreamChannel] in terms of | 41 /// A mixin that implements the instance methods of [StreamChannel] in terms of |
42 /// [stream] and [sink]. | 42 /// [stream] and [sink]. |
43 abstract class StreamChannelMixin<T> implements StreamChannel<T> { | 43 abstract class StreamChannelMixin<T> implements StreamChannel<T> { |
44 void pipe(StreamChannel<T> other) { | 44 void pipe(StreamChannel<T> other) { |
45 stream.pipe(other.sink); | 45 stream.pipe(other.sink); |
46 other.stream.pipe(sink); | 46 other.stream.pipe(sink); |
47 } | 47 } |
48 } | 48 } |
OLD | NEW |