OLD | NEW |
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 /** | 5 /** |
6 * *Warning*: this library is **internal**, and APIs are subject to change. | 6 * *Warning*: this library is **internal**, and APIs are subject to change. |
7 * | 7 * |
8 * Wraps a callback using [wrapMicrotask] and provides the ability to pump all | 8 * Wraps a callback using [wrapMicrotask] and provides the ability to pump all |
9 * observable objects and [scheduleMicrotask] calls via | 9 * observable objects and [scheduleMicrotask] calls via |
10 * [performMicrotaskCheckpoint]. | 10 * [performMicrotaskCheckpoint]. |
11 */ | 11 */ |
12 library observe.src.microtask; | 12 library observe.src.microtask; |
13 | 13 |
14 import 'dart:async' show Completer, runZonedExperimental; | 14 import 'dart:async' show Completer, runZoned, ZoneSpecification; |
15 import 'dart:collection'; | 15 import 'dart:collection'; |
16 import 'package:observe/observe.dart' show Observable; | 16 import 'package:observe/observe.dart' show Observable; |
17 | 17 |
18 // TODO(jmesserly): remove "microtask" from these names and instead import | 18 // TODO(jmesserly): remove "microtask" from these names and instead import |
19 // the library "as microtask"? | 19 // the library "as microtask"? |
20 | 20 |
21 /** | 21 /** |
22 * This change pumps events relevant to observers and data-binding tests. | 22 * This change pumps events relevant to observers and data-binding tests. |
23 * This must be used inside an [observeTest]. | 23 * This must be used inside an [observeTest]. |
24 * | 24 * |
(...skipping 29 matching lines...) Expand all Loading... |
54 * Wraps the [body] in a zone that supports [performMicrotaskCheckpoint], | 54 * Wraps the [body] in a zone that supports [performMicrotaskCheckpoint], |
55 * and returns the body. | 55 * and returns the body. |
56 */ | 56 */ |
57 // TODO(jmesserly): deprecate? this doesn't add much over runMicrotask. | 57 // TODO(jmesserly): deprecate? this doesn't add much over runMicrotask. |
58 wrapMicrotask(body()) => () => runMicrotask(body); | 58 wrapMicrotask(body()) => () => runMicrotask(body); |
59 | 59 |
60 /** | 60 /** |
61 * Runs the [body] in a zone that supports [performMicrotaskCheckpoint], | 61 * Runs the [body] in a zone that supports [performMicrotaskCheckpoint], |
62 * and returns the result. | 62 * and returns the result. |
63 */ | 63 */ |
64 runMicrotask(body()) => runZonedExperimental(() { | 64 runMicrotask(body()) => runZoned(() { |
65 try { | 65 try { |
66 return body(); | 66 return body(); |
67 } finally { | 67 } finally { |
68 performMicrotaskCheckpoint(); | 68 performMicrotaskCheckpoint(); |
69 } | 69 } |
70 }, onRunAsync: (callback) => _pending.add(callback)); | 70 }, zoneSpecification: new ZoneSpecification( |
| 71 scheduleMicrotask: (self, parent, zone, callback) => _pending.add(callback)) |
| 72 ); |
OLD | NEW |