OLD | NEW |
1 part of dart.async; | 1 part of dart.async; |
2 abstract class Future<T> {static final _Future _nullFuture = new Future.value(n
ull); | 2 abstract class Future<T> {static final _Future _nullFuture = new Future.value(n
ull); |
3 factory Future(computation()) { | 3 factory Future(computation()) { |
4 _Future result = new _Future<T>(); | 4 _Future result = new _Future<T>(); |
5 Timer.run(() { | 5 Timer.run(() { |
6 try { | 6 try { |
7 result._complete(computation()); | 7 result._complete(computation()); |
8 } | 8 } |
9 catch (e, s) { | 9 catch (e, s) { |
10 _completeWithErrorCallback(result, e, s); | 10 _completeWithErrorCallback(result, e, s); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (!iterator.moveNext()) return false; | 144 if (!iterator.moveNext()) return false; |
145 return new Future.sync(() => f(iterator.current)).then((_) => true); | 145 return new Future.sync(() => f(iterator.current)).then((_) => true); |
146 } | 146 } |
147 ); | 147 ); |
148 } | 148 } |
149 static Future doWhile(f()) { | 149 static Future doWhile(f()) { |
150 _Future doneSignal = new _Future(); | 150 _Future doneSignal = new _Future(); |
151 var nextIteration; | 151 var nextIteration; |
152 nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) { | 152 nextIteration = Zone.current.bindUnaryCallback((bool keepGoing) { |
153 if (keepGoing) { | 153 if (keepGoing) { |
154 new Future.sync(f).then(DEVC$RT.cast(nextIteration, dynamic, __t8, "Dynami
cCast", """line 361, column 33 of dart:async/future.dart: """, nextIteration is
__t8, true), onError: doneSignal._completeError); | 154 new Future.sync(f).then(DEVC$RT.cast(nextIteration, dynamic, __CastType8,
"DynamicCast", """line 361, column 33 of dart:async/future.dart: """, nextIterat
ion is __CastType8, true), onError: doneSignal._completeError); |
155 } | 155 } |
156 else { | 156 else { |
157 doneSignal._complete(null); | 157 doneSignal._complete(null); |
158 } | 158 } |
159 } | 159 } |
160 , runGuarded: true); | 160 , runGuarded: true); |
161 nextIteration(true); | 161 nextIteration(true); |
162 return doneSignal; | 162 return doneSignal; |
163 } | 163 } |
164 Future then(onValue(T value), { | 164 Future then(onValue(T value), { |
(...skipping 27 matching lines...) Expand all Loading... |
192 } | 192 } |
193 void _completeWithErrorCallback(_Future result, error, stackTrace) { | 193 void _completeWithErrorCallback(_Future result, error, stackTrace) { |
194 AsyncError replacement = Zone.current.errorCallback(error, DEVC$RT.cast(stackTra
ce, dynamic, StackTrace, "DynamicCast", """line 719, column 62 of dart:async/fut
ure.dart: """, stackTrace is StackTrace, true)); | 194 AsyncError replacement = Zone.current.errorCallback(error, DEVC$RT.cast(stackTra
ce, dynamic, StackTrace, "DynamicCast", """line 719, column 62 of dart:async/fut
ure.dart: """, stackTrace is StackTrace, true)); |
195 if (replacement != null) { | 195 if (replacement != null) { |
196 error = _nonNullError(replacement.error); | 196 error = _nonNullError(replacement.error); |
197 stackTrace = replacement.stackTrace; | 197 stackTrace = replacement.stackTrace; |
198 } | 198 } |
199 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Dyn
amicCast", """line 724, column 32 of dart:async/future.dart: """, stackTrace is
StackTrace, true)); | 199 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Dyn
amicCast", """line 724, column 32 of dart:async/future.dart: """, stackTrace is
StackTrace, true)); |
200 } | 200 } |
201 Object _nonNullError(Object error) => (error != null) ? error : new NullThrownE
rror(); | 201 Object _nonNullError(Object error) => (error != null) ? error : new NullThrownE
rror(); |
202 typedef dynamic __t8(dynamic __u9); | 202 typedef dynamic __CastType8(dynamic __u9); |
OLD | NEW |