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

Side by Side Diff: sdk/lib/async/stream.dart

Issue 1528363002: Update documentation on Stream.map (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comments. Created 5 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.async; 5 part of dart.async;
6 6
7 // ------------------------------------------------------------------- 7 // -------------------------------------------------------------------
8 // Core Stream types 8 // Core Stream types
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 * will individually perform the `test`. 306 * will individually perform the `test`.
307 */ 307 */
308 Stream<T> where(bool test(T event)) { 308 Stream<T> where(bool test(T event)) {
309 return new _WhereStream<T>(this, test); 309 return new _WhereStream<T>(this, test);
310 } 310 }
311 311
312 /** 312 /**
313 * Creates a new stream that converts each element of this stream 313 * Creates a new stream that converts each element of this stream
314 * to a new value using the [convert] function. 314 * to a new value using the [convert] function.
315 * 315 *
316 * For each data event, `o`, in this stream, the returned stream
317 * provides a data event with the value `convert(o)`.
318 * If [convert] throws, the returned stream reports the exception as an error
319 * event instead.
320 *
321 * Error and done events are passed through unchanged to the returned stream.
322 *
316 * The returned stream is a broadcast stream if this stream is. 323 * The returned stream is a broadcast stream if this stream is.
324 * The [convert] function is called once per data event per listener.
317 * If a broadcast stream is listened to more than once, each subscription 325 * If a broadcast stream is listened to more than once, each subscription
318 * will individually execute `map` for each event. 326 * will individually call [convert] on each data event.
319 */ 327 */
320 Stream/*<S>*/ map/*<S>*/(/*=S*/ convert(T event)) { 328 Stream/*<S>*/ map/*<S>*/(/*=S*/ convert(T event)) {
321 return new _MapStream<T, dynamic/*=S*/>(this, convert); 329 return new _MapStream<T, dynamic/*=S*/>(this, convert);
322 } 330 }
323 331
324 /** 332 /**
325 * Creates a new stream with each data event of this stream asynchronously 333 * Creates a new stream with each data event of this stream asynchronously
326 * mapped to a new event. 334 * mapped to a new event.
327 * 335 *
328 * This acts like [map], except that [convert] may return a [Future], 336 * This acts like [map], except that [convert] may return a [Future],
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1751 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1744 EventSink _sink; 1752 EventSink _sink;
1745 _ControllerEventSinkWrapper(this._sink); 1753 _ControllerEventSinkWrapper(this._sink);
1746 1754
1747 void add(T data) { _sink.add(data); } 1755 void add(T data) { _sink.add(data); }
1748 void addError(error, [StackTrace stackTrace]) { 1756 void addError(error, [StackTrace stackTrace]) {
1749 _sink.addError(error, stackTrace); 1757 _sink.addError(error, stackTrace);
1750 } 1758 }
1751 void close() { _sink.close(); } 1759 void close() { _sink.close(); }
1752 } 1760 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698