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

Side by Side Diff: lib/stream_channel.dart

Issue 2987963002: Update comment style generic syntax (Closed)
Patch Set: Created 3 years, 4 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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:async/async.dart'; 7 import 'package:async/async.dart';
8 8
9 import 'src/guarantee_channel.dart'; 9 import 'src/guarantee_channel.dart';
10 import 'src/close_guarantee_channel.dart'; 10 import 'src/close_guarantee_channel.dart';
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 StreamSink<T> sink) => 101 StreamSink<T> sink) =>
102 new CloseGuaranteeChannel(stream, sink); 102 new CloseGuaranteeChannel(stream, sink);
103 103
104 /// Connects [this] to [other], so that any values emitted by either are sent 104 /// Connects [this] to [other], so that any values emitted by either are sent
105 /// directly to the other. 105 /// directly to the other.
106 void pipe(StreamChannel<T> other); 106 void pipe(StreamChannel<T> other);
107 107
108 /// Transforms [this] using [transformer]. 108 /// Transforms [this] using [transformer].
109 /// 109 ///
110 /// This is identical to calling `transformer.bind(channel)`. 110 /// This is identical to calling `transformer.bind(channel)`.
111 StreamChannel/*<S>*/ transform/*<S>*/( 111 StreamChannel<S> transform<S>(
112 StreamChannelTransformer<dynamic/*=S*/, T> transformer); 112 StreamChannelTransformer<S, T> transformer);
113 113
114 /// Transforms only the [stream] component of [this] using [transformer]. 114 /// Transforms only the [stream] component of [this] using [transformer].
115 StreamChannel<T> transformStream(StreamTransformer<T, T> transformer); 115 StreamChannel<T> transformStream(StreamTransformer<T, T> transformer);
116 116
117 /// Transforms only the [sink] component of [this] using [transformer]. 117 /// Transforms only the [sink] component of [this] using [transformer].
118 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer); 118 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer);
119 119
120 /// Returns a copy of [this] with [stream] replaced by [change]'s return 120 /// Returns a copy of [this] with [stream] replaced by [change]'s return
121 /// value. 121 /// value.
122 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)); 122 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream));
123 123
124 /// Returns a copy of [this] with [sink] replaced by [change]'s return 124 /// Returns a copy of [this] with [sink] replaced by [change]'s return
125 /// value. 125 /// value.
126 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)); 126 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink));
127 127
128 /// Returns a copy of [this] with the generic type coerced to [S]. 128 /// Returns a copy of [this] with the generic type coerced to [S].
129 /// 129 ///
130 /// If any events emitted by [stream] aren't of type [S], they're converted 130 /// If any events emitted by [stream] aren't of type [S], they're converted
131 /// into [CastError] events. Similarly, if any events are added to [sync] that 131 /// into [CastError] events. Similarly, if any events are added to [sync] that
132 /// aren't of type [S], a [CastError] is thrown. 132 /// aren't of type [S], a [CastError] is thrown.
133 StreamChannel/*<S>*/ cast/*<S>*/(); 133 StreamChannel<S> cast<S>();
134 } 134 }
135 135
136 /// An implementation of [StreamChannel] that simply takes a stream and a sink 136 /// An implementation of [StreamChannel] that simply takes a stream and a sink
137 /// as parameters. 137 /// as parameters.
138 /// 138 ///
139 /// This is distinct from [StreamChannel] so that it can use 139 /// This is distinct from [StreamChannel] so that it can use
140 /// [StreamChannelMixin]. 140 /// [StreamChannelMixin].
141 class _StreamChannel<T> extends StreamChannelMixin<T> { 141 class _StreamChannel<T> extends StreamChannelMixin<T> {
142 final Stream<T> stream; 142 final Stream<T> stream;
143 final StreamSink<T> sink; 143 final StreamSink<T> sink;
144 144
145 _StreamChannel(this.stream, this.sink); 145 _StreamChannel(this.stream, this.sink);
146 } 146 }
147 147
148 /// A mixin that implements the instance methods of [StreamChannel] in terms of 148 /// A mixin that implements the instance methods of [StreamChannel] in terms of
149 /// [stream] and [sink]. 149 /// [stream] and [sink].
150 abstract class StreamChannelMixin<T> implements StreamChannel<T> { 150 abstract class StreamChannelMixin<T> implements StreamChannel<T> {
151 void pipe(StreamChannel<T> other) { 151 void pipe(StreamChannel<T> other) {
152 stream.pipe(other.sink); 152 stream.pipe(other.sink);
153 other.stream.pipe(sink); 153 other.stream.pipe(sink);
154 } 154 }
155 155
156 StreamChannel/*<S>*/ transform/*<S>*/( 156 StreamChannel<S> transform<S>(
157 StreamChannelTransformer<dynamic/*=S*/, T> transformer) => 157 StreamChannelTransformer<S, T> transformer) =>
158 transformer.bind(this); 158 transformer.bind(this);
159 159
160 StreamChannel<T> transformStream(StreamTransformer<T, T> transformer) => 160 StreamChannel<T> transformStream(StreamTransformer<T, T> transformer) =>
161 changeStream(transformer.bind); 161 changeStream(transformer.bind);
162 162
163 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer) => 163 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer) =>
164 changeSink(transformer.bind); 164 changeSink(transformer.bind);
165 165
166 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)) => 166 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)) =>
167 new StreamChannel.withCloseGuarantee(change(stream), sink); 167 new StreamChannel.withCloseGuarantee(change(stream), sink);
168 168
169 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)) => 169 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)) =>
170 new StreamChannel.withCloseGuarantee(stream, change(sink)); 170 new StreamChannel.withCloseGuarantee(stream, change(sink));
171 171
172 StreamChannel/*<S>*/ cast/*<S>*/() => new StreamChannel( 172 StreamChannel<S> cast<S>() => new StreamChannel(
173 DelegatingStream.typed(stream), DelegatingStreamSink.typed(sink)); 173 DelegatingStream.typed(stream), DelegatingStreamSink.typed(sink));
174 } 174 }
OLDNEW
« no previous file with comments | « lib/src/stream_channel_transformer.dart ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698