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 test.stream_channel; | |
6 | |
7 import 'dart:async'; | 5 import 'dart:async'; |
8 | 6 |
9 /// An abstract class representing a two-way communication channel. | 7 /// An abstract class representing a two-way communication channel. |
10 /// | 8 /// |
11 /// Subclasses can mix in [StreamChannelMixin] to get default implementations of | 9 /// Subclasses can mix in [StreamChannelMixin] to get default implementations of |
12 /// the various instance methods. | 10 /// the various instance methods. |
13 abstract class StreamChannel<T> { | 11 abstract class StreamChannel<T> { |
14 /// The stream that emits values from the other endpoint. | 12 /// The stream that emits values from the other endpoint. |
15 Stream<T> get stream; | 13 Stream<T> get stream; |
16 | 14 |
(...skipping 22 matching lines...) Expand all Loading... |
39 } | 37 } |
40 | 38 |
41 /// A mixin that implements the instance methods of [StreamChannel] in terms of | 39 /// A mixin that implements the instance methods of [StreamChannel] in terms of |
42 /// [stream] and [sink]. | 40 /// [stream] and [sink]. |
43 abstract class StreamChannelMixin<T> implements StreamChannel<T> { | 41 abstract class StreamChannelMixin<T> implements StreamChannel<T> { |
44 void pipe(StreamChannel<T> other) { | 42 void pipe(StreamChannel<T> other) { |
45 stream.pipe(other.sink); | 43 stream.pipe(other.sink); |
46 other.stream.pipe(sink); | 44 other.stream.pipe(sink); |
47 } | 45 } |
48 } | 46 } |
OLD | NEW |