Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Support for asynchronous programming, | 6 * Support for asynchronous programming, |
| 7 * with classes such as Future and Stream. | 7 * with classes such as Future and Stream. |
| 8 * | 8 * |
| 9 * Understanding [Future]s and [Stream]s is a prerequisite for | 9 * Understanding [Future]s and [Stream]s is a prerequisite for |
| 10 * writing just about any Dart program. | 10 * writing just about any Dart program. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 * is passed into the callback function. | 37 * is passed into the callback function. |
| 38 * In this example, the `bind()` method returns the HttpServer | 38 * In this example, the `bind()` method returns the HttpServer |
| 39 * object. The callback function prints one of its properties. | 39 * object. The callback function prints one of its properties. |
| 40 * [Future.catchError] registers a callback function that | 40 * [Future.catchError] registers a callback function that |
| 41 * runs if an error occurs within the Future. | 41 * runs if an error occurs within the Future. |
| 42 * | 42 * |
| 43 * ## Stream | 43 * ## Stream |
| 44 * | 44 * |
| 45 * A Stream provides an asynchronous sequence of data. | 45 * A Stream provides an asynchronous sequence of data. |
| 46 * Examples of data sequences include user-generated events, | 46 * Examples of data sequences include user-generated events, |
| 47 * such as mouse clicks, and a stream of bytes read from a file. | 47 * such as mouse clicks, and a stream of byte lists read from a file. |
|
Lasse Reichstein Nielsen
2014/03/18 11:57:14
How about:
... include individual events, like mou
Anders Johnsen
2014/03/18 12:30:57
Done.
| |
| 48 * The following example opens a file for reading. | 48 * The following example opens a file for reading. |
| 49 * [Stream.listen] registers a callback function that runs | 49 * [Stream.listen] registers a callback function that runs |
| 50 * each time more data is available. | 50 * each time more data is available. |
| 51 * | 51 * |
| 52 * Stream<List<int>> stream = new File('quotes.txt').openRead(); | 52 * Stream<List<int>> stream = new File('quotes.txt').openRead(); |
| 53 * stream.transform(UTF8.decoder).listen(print); | 53 * stream.transform(UTF8.decoder).listen(print); |
| 54 * | 54 * |
| 55 * The stream emits a sequence of a list of bytes. | 55 * The stream emits a sequence of a list of bytes. |
| 56 * The program must interpret the bytes or handle the raw byte data. | 56 * The program must interpret the bytes or handle the raw byte data. |
| 57 * Here, the code uses a UTF8 decoder (provided in the `dart:convert` library) | 57 * Here, the code uses a UTF8 decoder (provided in the `dart:convert` library) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 part 'future.dart'; | 97 part 'future.dart'; |
| 98 part 'future_impl.dart'; | 98 part 'future_impl.dart'; |
| 99 part 'schedule_microtask.dart'; | 99 part 'schedule_microtask.dart'; |
| 100 part 'stream.dart'; | 100 part 'stream.dart'; |
| 101 part 'stream_controller.dart'; | 101 part 'stream_controller.dart'; |
| 102 part 'stream_impl.dart'; | 102 part 'stream_impl.dart'; |
| 103 part 'stream_pipe.dart'; | 103 part 'stream_pipe.dart'; |
| 104 part 'stream_transformers.dart'; | 104 part 'stream_transformers.dart'; |
| 105 part 'timer.dart'; | 105 part 'timer.dart'; |
| 106 part 'zone.dart'; | 106 part 'zone.dart'; |
| OLD | NEW |