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

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

Issue 301193010: Update documentation for "close". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 * [futureValue]. 1331 * [futureValue].
1332 */ 1332 */
1333 Future asFuture([var futureValue]); 1333 Future asFuture([var futureValue]);
1334 } 1334 }
1335 1335
1336 1336
1337 /** 1337 /**
1338 * An interface that abstracts creation or handling of [Stream] events. 1338 * An interface that abstracts creation or handling of [Stream] events.
1339 */ 1339 */
1340 abstract class EventSink<T> implements Sink<T> { 1340 abstract class EventSink<T> implements Sink<T> {
1341 /** Create a data event */ 1341 /** Create a data event on the stream. */
1342 void add(T event); 1342 void add(T event);
1343 /** Create an async error. */ 1343 /** Create an async error on the stream. */
1344 void addError(errorEvent, [StackTrace stackTrace]); 1344 void addError(errorEvent, [StackTrace stackTrace]);
1345 /** Request a stream to close. */ 1345 /** Request a stream to close. This should also create a done event.*/
1346 void close(); 1346 void close();
1347 } 1347 }
1348 1348
1349 1349
1350 /** [Stream] wrapper that only exposes the [Stream] interface. */ 1350 /** [Stream] wrapper that only exposes the [Stream] interface. */
1351 class StreamView<T> extends Stream<T> { 1351 class StreamView<T> extends Stream<T> {
1352 Stream<T> _stream; 1352 Stream<T> _stream;
1353 1353
1354 StreamView(this._stream); 1354 StreamView(this._stream);
1355 1355
(...skipping 24 matching lines...) Expand all
1380 /** 1380 /**
1381 * Consumes the elements of [stream]. 1381 * Consumes the elements of [stream].
1382 * 1382 *
1383 * Listens on [stream] and does something for each event. 1383 * Listens on [stream] and does something for each event.
1384 * 1384 *
1385 * The consumer may stop listening after an error, or it may consume 1385 * The consumer may stop listening after an error, or it may consume
1386 * all the errors and only stop at a done event. 1386 * all the errors and only stop at a done event.
1387 */ 1387 */
1388 Future addStream(Stream<S> stream); 1388 Future addStream(Stream<S> stream);
1389 1389
1390 /**
1391 * Tell the consumer that no futher streams will be added.
1392 *
1393 * Returns a future that is completed when the consumer is done handling
1394 * events.
1395 */
1390 Future close(); 1396 Future close();
1391 } 1397 }
1392 1398
1393 1399
1394 /** 1400 /**
1395 * A [StreamSink] unifies the asynchronous methods from [StreamConsumer] and 1401 * A [StreamSink] unifies the asynchronous methods from [StreamConsumer] and
1396 * the synchronous methods from [EventSink]. 1402 * the synchronous methods from [EventSink].
1397 * 1403 *
1398 * The [EventSink] methods can't be used while the [addStream] is called. 1404 * The [EventSink] methods can't be used while the [addStream] is called.
1399 * As soon as the [addStream]'s [Future] completes with a value, the 1405 * As soon as the [addStream]'s [Future] completes with a value, the
1400 * [EventSink] methods can be used again. 1406 * [EventSink] methods can be used again.
1401 * 1407 *
1402 * If [addStream] is called after any of the [EventSink] methods, it'll 1408 * If [addStream] is called after any of the [EventSink] methods, it'll
1403 * be delayed until the underlying system has consumed the data added by the 1409 * be delayed until the underlying system has consumed the data added by the
1404 * [EventSink] methods. 1410 * [EventSink] methods.
1405 * 1411 *
1406 * When [EventSink] methods are used, the [done] [Future] can be used to 1412 * When [EventSink] methods are used, the [done] [Future] can be used to
1407 * catch any errors. 1413 * catch any errors.
1408 * 1414 *
1409 * When [close] is called, it will return the [done] [Future]. 1415 * When [close] is called, it will return the [done] [Future].
1410 */ 1416 */
1411 abstract class StreamSink<S> implements StreamConsumer<S>, EventSink<S> { 1417 abstract class StreamSink<S> implements StreamConsumer<S>, EventSink<S> {
1412 /** 1418 /**
1413 * Close the [StreamSink]. It'll return the [done] Future. 1419 * Send a done event, as the [EventSink.close].
1420 *
1421 * Returns a future which is completed when the close operation is complete.
1414 */ 1422 */
1415 Future close(); 1423 Future close();
1416 1424
1417 /** 1425 /**
1418 * The [done] Future completes with the same values as [close], except 1426 * Return a future which is completed when the [StreamSink] is cloed.
1419 * for the following case: 1427 *
1428 * The [done] Future completes with the same value as the future returned
1429 * by [close], except for the following case:
1420 * 1430 *
1421 * * The synchronous methods of [EventSink] were called, resulting in an 1431 * * The synchronous methods of [EventSink] were called, resulting in an
1422 * error. If there is no active future (like from an addStream call), the 1432 * error. If there is no active future (like from an addStream call), the
1423 * [done] future will complete with that error 1433 * [done] future will complete with that error
1424 */ 1434 */
1435 // TODO: What does this mean?
Lasse Reichstein Nielsen 2014/06/02 07:21:51 I've tried to read the previous documentation, and
1425 Future get done; 1436 Future get done;
1426 } 1437 }
1427 1438
1428 1439
1429 /** 1440 /**
1430 * The target of a [Stream.transform] call. 1441 * The target of a [Stream.transform] call.
1431 * 1442 *
1432 * The [Stream.transform] call will pass itself to this object and then return 1443 * The [Stream.transform] call will pass itself to this object and then return
1433 * the resulting stream. 1444 * the resulting stream.
1434 * 1445 *
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1594 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1584 EventSink _sink; 1595 EventSink _sink;
1585 _ControllerEventSinkWrapper(this._sink); 1596 _ControllerEventSinkWrapper(this._sink);
1586 1597
1587 void add(T data) { _sink.add(data); } 1598 void add(T data) { _sink.add(data); }
1588 void addError(error, [StackTrace stackTrace]) { 1599 void addError(error, [StackTrace stackTrace]) {
1589 _sink.addError(error, stackTrace); 1600 _sink.addError(error, stackTrace);
1590 } 1601 }
1591 void close() { _sink.close(); } 1602 void close() { _sink.close(); }
1592 } 1603 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698