Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: lib/src/util/stream_channel.dart

Issue 959383004: Add a host script to run in a browser and start iframes for suites. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 unittest.stream_channel;
6
7 import 'dart:async';
8
9 /// An abstract class representing a two-way communication channel.
10 ///
11 /// Subclasses can extend [StreamChannelMixin] to get default implementations of
Bob Nystrom 2015/03/02 20:31:31 "extend" -> "mix in".
nweiz 2015/03/02 22:39:42 Done.
12 /// the various instance methods.
13 abstract class StreamChannel<T> {
14 /// The stream that emits values from the other endpoint.
15 Stream<T> get stream;
16
17 /// The sink for sending values to the other endpoint.
18 StreamSink<T> get sink;
19
20 /// Creates a new [StreamChannel] that communicates over [stream] and [sink].
21 factory StreamChannel(Stream<T> stream, StreamSink<T> sink) =>
22 new _StreamChannel<T>(stream, sink);
23
24 /// Connects [this] to [other], so that any values emitted by either are sent
25 /// directly to the other.
26 void pipe(StreamChannel<T> other);
27 }
28
29 /// An implementation of [StreamChannel] that simply takes a stream and a sink
30 /// as parameters.
31 ///
32 /// This is distinct from [StreamChannel] so that it can use
33 /// [StreamChannelMixin].
34 class _StreamChannel<T> extends StreamChannelMixin<T> {
35 final Stream<T> stream;
36 final StreamSink<T> sink;
37
38 _StreamChannel(this.stream, this.sink);
39 }
40
41 /// A mixin that implements the instance methods of [StreamChannel] in terms of
42 /// [stream] and [sink].
43 abstract class StreamChannelMixin<T> implements StreamChannel<T> {
44 void pipe(StreamChannel<T> other) {
45 stream.pipe(other.sink);
46 other.stream.pipe(sink);
47 }
48 }
OLDNEW
« lib/src/runner/browser/static/index.html ('K') | « lib/src/util/multi_channel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698