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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 * to convert the sequence of bytes into a sequence | 60 * to convert the sequence of bytes into a sequence |
61 * of Dart strings. | 61 * of Dart strings. |
62 * | 62 * |
63 * Another common use of streams is for user-generated events | 63 * Another common use of streams is for user-generated events |
64 * in a web app: The following code listens for mouse clicks on a button. | 64 * in a web app: The following code listens for mouse clicks on a button. |
65 * | 65 * |
66 * querySelector('#myButton').onClick.listen((_) => print('Click.')); | 66 * querySelector('#myButton').onClick.listen((_) => print('Click.')); |
67 * | 67 * |
68 * ## Other resources | 68 * ## Other resources |
69 * | 69 * |
70 * * The [dart:async section of the library tour] | 70 * * The [dart:async section of the library tour][asynchronous-programming]: |
71 * (https://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html#ch03-as
ynchronous-programming): | 71 * A brief overview of asynchronous programming. |
72 * A brief overview of asynchronous programming. | |
73 * | 72 * |
74 * * [Use Future-Based APIs] | 73 * * [Use Future-Based APIs][futures-tutorial]: A closer look at Futures and |
75 * (https://www.dartlang.org/docs/tutorials/futures/): A closer look at | 74 * how to use them to write asynchronous Dart code. |
76 * Futures and how to use them to write asynchronous Dart code. | |
77 * | 75 * |
78 * * [Futures and Error Handling] | 76 * * [Futures and Error Handling][futures-error-handling]: Everything you |
79 * (https://www.dartlang.org/articles/futures-and-error-handling/): Everything | 77 * wanted to know about handling errors and exceptions when working with |
80 * you wanted to know about handling errors and exceptions when working with | 78 * Futures (but were afraid to ask). |
81 * Futures (but were afraid to ask). | |
82 * | 79 * |
83 * * [The Event Loop and Dart](https://www.dartlang.org/articles/event-loop/): | 80 * * [The Event Loop and Dart](https://www.dartlang.org/articles/event-loop/): |
84 * Learn how Dart handles the event queue and microtask queue, so you can write | 81 * Learn how Dart handles the event queue and microtask queue, so you can |
85 * better asynchronous code with fewer surprises. | 82 * write better asynchronous code with fewer surprises. |
86 * | 83 * |
87 * * [Asynchronous Unit Testing with Dart] | 84 * * [test package: Asynchronous Tests][test-readme]: How to test asynchronous |
88 * (https://www.dartlang.org/articles/dart-unit-tests/#asynchronous-tests): How | 85 * code. |
89 * to test asynchronous code. | 86 * |
| 87 * [asynchronous-programming]: https://www.dartlang.org/docs/dart-up-and-running
/ch03.html#dartasync---asynchronous-programming |
| 88 * [futures-tutorial]: https://www.dartlang.org/docs/tutorials/futures/ |
| 89 * [futures-error-handling]: https://www.dartlang.org/articles/futures-and-error
-handling/ |
| 90 * [test-readme]: https://pub.dartlang.org/packages/test |
90 */ | 91 */ |
91 library dart.async; | 92 library dart.async; |
92 | 93 |
93 import "dart:collection"; | 94 import "dart:collection"; |
94 import "dart:_internal" show printToZone, printToConsole, | 95 import "dart:_internal" show printToZone, printToConsole, |
95 IterableElementError; | 96 IterableElementError; |
96 | 97 |
97 part 'async_error.dart'; | 98 part 'async_error.dart'; |
98 part 'broadcast_stream_controller.dart'; | 99 part 'broadcast_stream_controller.dart'; |
99 part 'deferred_load.dart'; | 100 part 'deferred_load.dart'; |
100 part 'future.dart'; | 101 part 'future.dart'; |
101 part 'future_impl.dart'; | 102 part 'future_impl.dart'; |
102 part 'schedule_microtask.dart'; | 103 part 'schedule_microtask.dart'; |
103 part 'stream.dart'; | 104 part 'stream.dart'; |
104 part 'stream_controller.dart'; | 105 part 'stream_controller.dart'; |
105 part 'stream_impl.dart'; | 106 part 'stream_impl.dart'; |
106 part 'stream_pipe.dart'; | 107 part 'stream_pipe.dart'; |
107 part 'stream_transformers.dart'; | 108 part 'stream_transformers.dart'; |
108 part 'timer.dart'; | 109 part 'timer.dart'; |
109 part 'zone.dart'; | 110 part 'zone.dart'; |
OLD | NEW |