OLD | NEW |
1 var async = dart.defineLibrary(async, {}); | 1 var async = dart.defineLibrary(async, {}); |
2 var core = dart.import(core); | 2 var core = dart.import(core); |
3 var _internal = dart.import(_internal); | 3 var _internal = dart.import(_internal); |
4 var _js_helper = dart.lazyImport(_js_helper); | 4 var _js_helper = dart.lazyImport(_js_helper); |
5 var _isolate_helper = dart.lazyImport(_isolate_helper); | 5 var _isolate_helper = dart.lazyImport(_isolate_helper); |
6 var collection = dart.import(collection); | 6 var collection = dart.import(collection); |
7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) { | 7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) { |
8 'use strict'; | 8 'use strict'; |
9 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic | 9 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic |
10 function _invokeErrorHandler(errorHandler, error, stackTrace) { | 10 function _invokeErrorHandler(errorHandler, error, stackTrace) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 periodic(period, computation) { | 86 periodic(period, computation) { |
87 if (computation === void 0) | 87 if (computation === void 0) |
88 computation = null; | 88 computation = null; |
89 if (computation == null) | 89 if (computation == null) |
90 computation = i => null; | 90 computation = i => null; |
91 let timer = null; | 91 let timer = null; |
92 let computationCount = 0; | 92 let computationCount = 0; |
93 let controller = null; | 93 let controller = null; |
94 let watch = new core.Stopwatch(); | 94 let watch = new core.Stopwatch(); |
95 // Function sendEvent: () → void | 95 // Function sendEvent: () → void |
96 function sendEvent() { | 96 let sendEvent = () => { |
97 watch.reset(); | 97 watch.reset(); |
98 let data = computation((() => { | 98 let data = computation((() => { |
99 let x = computationCount; | 99 let x = computationCount; |
100 computationCount = dart.notNull(x) + 1; | 100 computationCount = dart.notNull(x) + 1; |
101 return x; | 101 return x; |
102 })()); | 102 })()); |
103 controller.add(data); | 103 controller.add(data); |
104 } | 104 }; |
105 // Function startPeriodicTimer: () → void | 105 // Function startPeriodicTimer: () → void |
106 function startPeriodicTimer() { | 106 let startPeriodicTimer = () => { |
107 dart.assert(timer == null); | 107 dart.assert(timer == null); |
108 timer = new Timer.periodic(period, timer => { | 108 timer = new Timer.periodic(period, timer => { |
109 sendEvent(); | 109 sendEvent(); |
110 }); | 110 }); |
111 } | 111 }; |
112 controller = new (StreamController$(T))({ | 112 controller = new (StreamController$(T))({ |
113 sync: true, | 113 sync: true, |
114 onListen: () => { | 114 onListen: () => { |
115 watch.start(); | 115 watch.start(); |
116 startPeriodicTimer(); | 116 startPeriodicTimer(); |
117 }, | 117 }, |
118 onPause: () => { | 118 onPause: () => { |
119 timer.cancel(); | 119 timer.cancel(); |
120 timer = null; | 120 timer = null; |
121 watch.stop(); | 121 watch.stop(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 map(convert) { | 158 map(convert) { |
159 dart.as(convert, dart.functionType(dart.dynamic, [T])); | 159 dart.as(convert, dart.functionType(dart.dynamic, [T])); |
160 return new (_MapStream$(T, dart.dynamic))(this, convert); | 160 return new (_MapStream$(T, dart.dynamic))(this, convert); |
161 } | 161 } |
162 asyncMap(convert) { | 162 asyncMap(convert) { |
163 dart.as(convert, dart.functionType(dart.dynamic, [T])); | 163 dart.as(convert, dart.functionType(dart.dynamic, [T])); |
164 let controller = null; | 164 let controller = null; |
165 let subscription = null; | 165 let subscription = null; |
166 // Function onListen: () → void | 166 // Function onListen: () → void |
167 function onListen() { | 167 let onListen = (() => { |
168 let add = controller.add.bind(controller); | 168 let add = controller.add.bind(controller); |
169 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 169 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
170 let eventSink = controller; | 170 let eventSink = controller; |
171 let addError = eventSink[_addError]; | 171 let addError = eventSink[_addError]; |
172 subscription = this.listen(event => { | 172 subscription = this.listen(event => { |
173 dart.as(event, T); | 173 dart.as(event, T); |
174 let newValue = null; | 174 let newValue = null; |
175 try { | 175 try { |
176 newValue = convert(event); | 176 newValue = convert(event); |
177 } catch (e) { | 177 } catch (e) { |
178 let s = dart.stackTrace(e); | 178 let s = dart.stackTrace(e); |
179 controller.addError(e, s); | 179 controller.addError(e, s); |
180 return; | 180 return; |
181 } | 181 } |
182 | 182 |
183 if (dart.is(newValue, Future)) { | 183 if (dart.is(newValue, Future)) { |
184 subscription.pause(); | 184 subscription.pause(); |
185 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}),
'whenComplete', dart.bind(subscription, 'resume')); | 185 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}),
'whenComplete', dart.bind(subscription, 'resume')); |
186 } else { | 186 } else { |
187 controller.add(newValue); | 187 controller.add(newValue); |
188 } | 188 } |
189 }, {onError: dart.as(addError, core.Function), onDone: controller.clos
e.bind(controller)}); | 189 }, {onError: dart.as(addError, core.Function), onDone: controller.clos
e.bind(controller)}); |
190 } | 190 }).bind(this); |
191 if (this.isBroadcast) { | 191 if (this.isBroadcast) { |
192 controller = new StreamController.broadcast({ | 192 controller = new StreamController.broadcast({ |
193 onListen: onListen, | 193 onListen: onListen, |
194 onCancel: () => { | 194 onCancel: () => { |
195 subscription.cancel(); | 195 subscription.cancel(); |
196 }, | 196 }, |
197 sync: true | 197 sync: true |
198 }); | 198 }); |
199 } else { | 199 } else { |
200 controller = new StreamController({ | 200 controller = new StreamController({ |
(...skipping 10 matching lines...) Expand all Loading... |
211 sync: true | 211 sync: true |
212 }); | 212 }); |
213 } | 213 } |
214 return controller.stream; | 214 return controller.stream; |
215 } | 215 } |
216 asyncExpand(convert) { | 216 asyncExpand(convert) { |
217 dart.as(convert, dart.functionType(Stream, [T])); | 217 dart.as(convert, dart.functionType(Stream, [T])); |
218 let controller = null; | 218 let controller = null; |
219 let subscription = null; | 219 let subscription = null; |
220 // Function onListen: () → void | 220 // Function onListen: () → void |
221 function onListen() { | 221 let onListen = (() => { |
222 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 222 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
223 let eventSink = controller; | 223 let eventSink = controller; |
224 subscription = this.listen(event => { | 224 subscription = this.listen(event => { |
225 dart.as(event, T); | 225 dart.as(event, T); |
226 let newStream = null; | 226 let newStream = null; |
227 try { | 227 try { |
228 newStream = convert(event); | 228 newStream = convert(event); |
229 } catch (e) { | 229 } catch (e) { |
230 let s = dart.stackTrace(e); | 230 let s = dart.stackTrace(e); |
231 controller.addError(e, s); | 231 controller.addError(e, s); |
232 return; | 232 return; |
233 } | 233 } |
234 | 234 |
235 if (newStream != null) { | 235 if (newStream != null) { |
236 subscription.pause(); | 236 subscription.pause(); |
237 controller.addStream(newStream).whenComplete(dart.bind(subscriptio
n, 'resume')); | 237 controller.addStream(newStream).whenComplete(dart.bind(subscriptio
n, 'resume')); |
238 } | 238 } |
239 }, {onError: dart.as(eventSink[_addError], core.Function), onDone: con
troller.close.bind(controller)}); | 239 }, {onError: dart.as(eventSink[_addError], core.Function), onDone: con
troller.close.bind(controller)}); |
240 } | 240 }).bind(this); |
241 if (this.isBroadcast) { | 241 if (this.isBroadcast) { |
242 controller = new StreamController.broadcast({ | 242 controller = new StreamController.broadcast({ |
243 onListen: onListen, | 243 onListen: onListen, |
244 onCancel: () => { | 244 onCancel: () => { |
245 subscription.cancel(); | 245 subscription.cancel(); |
246 }, | 246 }, |
247 sync: true | 247 sync: true |
248 }); | 248 }); |
249 } else { | 249 } else { |
250 controller = new StreamController({ | 250 controller = new StreamController({ |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 } | 752 } |
753 timeout(timeLimit, opts) { | 753 timeout(timeLimit, opts) { |
754 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; | 754 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; |
755 dart.as(onTimeout, dart.functionType(dart.void, [EventSink])); | 755 dart.as(onTimeout, dart.functionType(dart.void, [EventSink])); |
756 let controller = null; | 756 let controller = null; |
757 let subscription = null; | 757 let subscription = null; |
758 let timer = null; | 758 let timer = null; |
759 let zone = null; | 759 let zone = null; |
760 let timeout = null; | 760 let timeout = null; |
761 // Function onData: (T) → void | 761 // Function onData: (T) → void |
762 function onData(event) { | 762 let onData = event => { |
763 dart.as(event, T); | 763 dart.as(event, T); |
764 timer.cancel(); | 764 timer.cancel(); |
765 controller.add(event); | 765 controller.add(event); |
766 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType17)); | 766 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType17)); |
767 } | 767 }; |
768 // Function onError: (dynamic, StackTrace) → void | 768 // Function onError: (dynamic, StackTrace) → void |
769 function onError(error, stackTrace) { | 769 let onError = (error, stackTrace) => { |
770 timer.cancel(); | 770 timer.cancel(); |
771 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 771 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
772 let eventSink = controller; | 772 let eventSink = controller; |
773 dart.dcall(eventSink[_addError], error, stackTrace); | 773 dart.dcall(eventSink[_addError], error, stackTrace); |
774 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); | 774 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); |
775 } | 775 }; |
776 // Function onDone: () → void | 776 // Function onDone: () → void |
777 function onDone() { | 777 let onDone = () => { |
778 timer.cancel(); | 778 timer.cancel(); |
779 controller.close(); | 779 controller.close(); |
780 } | 780 }; |
781 // Function onListen: () → void | 781 // Function onListen: () → void |
782 function onListen() { | 782 let onListen = (() => { |
783 zone = Zone.current; | 783 zone = Zone.current; |
784 if (onTimeout == null) { | 784 if (onTimeout == null) { |
785 timeout = () => { | 785 timeout = () => { |
786 controller.addError(new TimeoutException("No stream event", timeLi
mit), null); | 786 controller.addError(new TimeoutException("No stream event", timeLi
mit), null); |
787 }; | 787 }; |
788 } else { | 788 } else { |
789 onTimeout = dart.as(zone.registerUnaryCallback(onTimeout), __CastTyp
e18); | 789 onTimeout = dart.as(zone.registerUnaryCallback(onTimeout), __CastTyp
e18); |
790 let wrapper = new _ControllerEventSinkWrapper(null); | 790 let wrapper = new _ControllerEventSinkWrapper(null); |
791 timeout = () => { | 791 timeout = () => { |
792 wrapper[_sink] = controller; | 792 wrapper[_sink] = controller; |
793 zone.runUnaryGuarded(onTimeout, wrapper); | 793 zone.runUnaryGuarded(onTimeout, wrapper); |
794 wrapper[_sink] = null; | 794 wrapper[_sink] = null; |
795 }; | 795 }; |
796 } | 796 } |
797 subscription = this.listen(onData, {onError: onError, onDone: onDone})
; | 797 subscription = this.listen(onData, {onError: onError, onDone: onDone})
; |
798 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); | 798 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); |
799 } | 799 }).bind(this); |
800 // Function onCancel: () → Future<dynamic> | 800 // Function onCancel: () → Future<dynamic> |
801 function onCancel() { | 801 let onCancel = () => { |
802 timer.cancel(); | 802 timer.cancel(); |
803 let result = subscription.cancel(); | 803 let result = subscription.cancel(); |
804 subscription = null; | 804 subscription = null; |
805 return result; | 805 return result; |
806 } | 806 }; |
807 controller = this.isBroadcast ? new _SyncBroadcastStreamController(onLis
ten, onCancel) : new _SyncStreamController(onListen, () => { | 807 controller = this.isBroadcast ? new _SyncBroadcastStreamController(onLis
ten, onCancel) : new _SyncStreamController(onListen, () => { |
808 timer.cancel(); | 808 timer.cancel(); |
809 subscription.pause(); | 809 subscription.pause(); |
810 }, () => { | 810 }, () => { |
811 subscription.resume(); | 811 subscription.resume(); |
812 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); | 812 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); |
813 }, onCancel); | 813 }, onCancel); |
814 return controller.stream; | 814 return controller.stream; |
815 } | 815 } |
816 } | 816 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 this[_zone].runUnaryGuarded(this[_onData], data); | 1144 this[_zone].runUnaryGuarded(this[_onData], data); |
1145 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre
amSubscription._STATE_IN_CALLBACK); | 1145 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre
amSubscription._STATE_IN_CALLBACK); |
1146 this[_checkState](wasInputPaused); | 1146 this[_checkState](wasInputPaused); |
1147 } | 1147 } |
1148 [_sendError](error, stackTrace) { | 1148 [_sendError](error, stackTrace) { |
1149 dart.assert(!dart.notNull(this[_isCanceled])); | 1149 dart.assert(!dart.notNull(this[_isCanceled])); |
1150 dart.assert(!dart.notNull(this[_isPaused])); | 1150 dart.assert(!dart.notNull(this[_isPaused])); |
1151 dart.assert(!dart.notNull(this[_inCallback])); | 1151 dart.assert(!dart.notNull(this[_inCallback])); |
1152 let wasInputPaused = this[_isInputPaused]; | 1152 let wasInputPaused = this[_isInputPaused]; |
1153 // Function sendError: () → void | 1153 // Function sendError: () → void |
1154 function sendError() { | 1154 let sendError = (() => { |
1155 if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCan
cel])) | 1155 if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCan
cel])) |
1156 return; | 1156 return; |
1157 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_IN_CALLBACK); | 1157 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_IN_CALLBACK); |
1158 if (dart.is(this[_onError], ZoneBinaryCallback)) { | 1158 if (dart.is(this[_onError], ZoneBinaryCallback)) { |
1159 this[_zone].runBinaryGuarded(dart.as(this[_onError], __CastType22),
error, stackTrace); | 1159 this[_zone].runBinaryGuarded(dart.as(this[_onError], __CastType22),
error, stackTrace); |
1160 } else { | 1160 } else { |
1161 this[_zone].runUnaryGuarded(dart.as(this[_onError], __CastType25), e
rror); | 1161 this[_zone].runUnaryGuarded(dart.as(this[_onError], __CastType25), e
rror); |
1162 } | 1162 } |
1163 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt
reamSubscription._STATE_IN_CALLBACK); | 1163 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt
reamSubscription._STATE_IN_CALLBACK); |
1164 } | 1164 }).bind(this); |
1165 if (this[_cancelOnError]) { | 1165 if (this[_cancelOnError]) { |
1166 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_WAIT_FOR_CANCEL); | 1166 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_WAIT_FOR_CANCEL); |
1167 this[_cancel](); | 1167 this[_cancel](); |
1168 if (dart.is(this[_cancelFuture], Future)) { | 1168 if (dart.is(this[_cancelFuture], Future)) { |
1169 this[_cancelFuture].whenComplete(sendError); | 1169 this[_cancelFuture].whenComplete(sendError); |
1170 } else { | 1170 } else { |
1171 sendError(); | 1171 sendError(); |
1172 } | 1172 } |
1173 } else { | 1173 } else { |
1174 sendError(); | 1174 sendError(); |
1175 this[_checkState](wasInputPaused); | 1175 this[_checkState](wasInputPaused); |
1176 } | 1176 } |
1177 } | 1177 } |
1178 [_sendDone]() { | 1178 [_sendDone]() { |
1179 dart.assert(!dart.notNull(this[_isCanceled])); | 1179 dart.assert(!dart.notNull(this[_isCanceled])); |
1180 dart.assert(!dart.notNull(this[_isPaused])); | 1180 dart.assert(!dart.notNull(this[_isPaused])); |
1181 dart.assert(!dart.notNull(this[_inCallback])); | 1181 dart.assert(!dart.notNull(this[_inCallback])); |
1182 // Function sendDone: () → void | 1182 // Function sendDone: () → void |
1183 function sendDone() { | 1183 let sendDone = (() => { |
1184 if (!dart.notNull(this[_waitsForCancel])) | 1184 if (!dart.notNull(this[_waitsForCancel])) |
1185 return; | 1185 return; |
1186 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription._ST
ATE_CLOSED) | dart.notNull(_BufferingStreamSubscription._STATE_IN_CALLBACK); | 1186 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr
eamSubscription._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription._ST
ATE_CLOSED) | dart.notNull(_BufferingStreamSubscription._STATE_IN_CALLBACK); |
1187 this[_zone].runGuarded(this[_onDone]); | 1187 this[_zone].runGuarded(this[_onDone]); |
1188 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt
reamSubscription._STATE_IN_CALLBACK); | 1188 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt
reamSubscription._STATE_IN_CALLBACK); |
1189 } | 1189 }).bind(this); |
1190 this[_cancel](); | 1190 this[_cancel](); |
1191 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea
mSubscription._STATE_WAIT_FOR_CANCEL); | 1191 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea
mSubscription._STATE_WAIT_FOR_CANCEL); |
1192 if (dart.is(this[_cancelFuture], Future)) { | 1192 if (dart.is(this[_cancelFuture], Future)) { |
1193 this[_cancelFuture].whenComplete(sendDone); | 1193 this[_cancelFuture].whenComplete(sendDone); |
1194 } else { | 1194 } else { |
1195 sendDone(); | 1195 sendDone(); |
1196 } | 1196 } |
1197 } | 1197 } |
1198 [_guardCallback](callback) { | 1198 [_guardCallback](callback) { |
1199 dart.assert(!dart.notNull(this[_inCallback])); | 1199 dart.assert(!dart.notNull(this[_inCallback])); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 static wait(futures, opts) { | 1822 static wait(futures, opts) { |
1823 let eagerError = opts && 'eagerError' in opts ? opts.eagerError : false; | 1823 let eagerError = opts && 'eagerError' in opts ? opts.eagerError : false; |
1824 let cleanUp = opts && 'cleanUp' in opts ? opts.cleanUp : null; | 1824 let cleanUp = opts && 'cleanUp' in opts ? opts.cleanUp : null; |
1825 dart.as(cleanUp, dart.functionType(dart.void, [dart.dynamic])); | 1825 dart.as(cleanUp, dart.functionType(dart.void, [dart.dynamic])); |
1826 let result = new (_Future$(core.List))(); | 1826 let result = new (_Future$(core.List))(); |
1827 let values = null; | 1827 let values = null; |
1828 let remaining = 0; | 1828 let remaining = 0; |
1829 let error = null; | 1829 let error = null; |
1830 let stackTrace = null; | 1830 let stackTrace = null; |
1831 // Function handleError: (dynamic, dynamic) → void | 1831 // Function handleError: (dynamic, dynamic) → void |
1832 function handleError(theError, theStackTrace) { | 1832 let handleError = (theError, theStackTrace) => { |
1833 remaining = dart.notNull(remaining) - 1; | 1833 remaining = dart.notNull(remaining) - 1; |
1834 if (values != null) { | 1834 if (values != null) { |
1835 if (cleanUp != null) { | 1835 if (cleanUp != null) { |
1836 for (let value of values) { | 1836 for (let value of values) { |
1837 if (value != null) { | 1837 if (value != null) { |
1838 new Future.sync(() => { | 1838 new Future.sync(() => { |
1839 dart.dcall(cleanUp, value); | 1839 dart.dcall(cleanUp, value); |
1840 }); | 1840 }); |
1841 } | 1841 } |
1842 } | 1842 } |
1843 } | 1843 } |
1844 values = null; | 1844 values = null; |
1845 if (remaining == 0 || dart.notNull(eagerError)) { | 1845 if (remaining == 0 || dart.notNull(eagerError)) { |
1846 result[_completeError](theError, dart.as(theStackTrace, core.Stack
Trace)); | 1846 result[_completeError](theError, dart.as(theStackTrace, core.Stack
Trace)); |
1847 } else { | 1847 } else { |
1848 error = theError; | 1848 error = theError; |
1849 stackTrace = dart.as(theStackTrace, core.StackTrace); | 1849 stackTrace = dart.as(theStackTrace, core.StackTrace); |
1850 } | 1850 } |
1851 } else if (remaining == 0 && !dart.notNull(eagerError)) { | 1851 } else if (remaining == 0 && !dart.notNull(eagerError)) { |
1852 result[_completeError](error, stackTrace); | 1852 result[_completeError](error, stackTrace); |
1853 } | 1853 } |
1854 } | 1854 }; |
1855 for (let future of futures) { | 1855 for (let future of futures) { |
1856 let pos = remaining; | 1856 let pos = remaining; |
1857 remaining = dart.notNull(pos) + 1; | 1857 remaining = dart.notNull(pos) + 1; |
1858 future.then(value => { | 1858 future.then(value => { |
1859 remaining = dart.notNull(remaining) - 1; | 1859 remaining = dart.notNull(remaining) - 1; |
1860 if (values != null) { | 1860 if (values != null) { |
1861 values[core.$set](pos, value); | 1861 values[core.$set](pos, value); |
1862 if (remaining == 0) { | 1862 if (remaining == 0) { |
1863 result[_completeWithValue](values); | 1863 result[_completeWithValue](values); |
1864 } | 1864 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2373 if (dart.notNull(hasError) && !dart.notNull(source[_zone].inSameErro
rZone(zone))) { | 2373 if (dart.notNull(hasError) && !dart.notNull(source[_zone].inSameErro
rZone(zone))) { |
2374 let asyncError = source[_error]; | 2374 let asyncError = source[_error]; |
2375 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta
ckTrace); | 2375 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta
ckTrace); |
2376 return; | 2376 return; |
2377 } | 2377 } |
2378 let oldZone = null; | 2378 let oldZone = null; |
2379 if (!dart.notNull(core.identical(Zone.current, zone))) { | 2379 if (!dart.notNull(core.identical(Zone.current, zone))) { |
2380 oldZone = Zone._enter(zone); | 2380 oldZone = Zone._enter(zone); |
2381 } | 2381 } |
2382 // Function handleValueCallback: () → bool | 2382 // Function handleValueCallback: () → bool |
2383 function handleValueCallback() { | 2383 let handleValueCallback = () => { |
2384 try { | 2384 try { |
2385 listenerValueOrError = zone.runUnary(listener[_onValue], sourceV
alue); | 2385 listenerValueOrError = zone.runUnary(listener[_onValue], sourceV
alue); |
2386 return true; | 2386 return true; |
2387 } catch (e) { | 2387 } catch (e) { |
2388 let s = dart.stackTrace(e); | 2388 let s = dart.stackTrace(e); |
2389 listenerValueOrError = new AsyncError(e, s); | 2389 listenerValueOrError = new AsyncError(e, s); |
2390 return false; | 2390 return false; |
2391 } | 2391 } |
2392 | 2392 |
2393 } | 2393 }; |
2394 // Function handleError: () → void | 2394 // Function handleError: () → void |
2395 function handleError() { | 2395 let handleError = () => { |
2396 let asyncError = source[_error]; | 2396 let asyncError = source[_error]; |
2397 let matchesTest = true; | 2397 let matchesTest = true; |
2398 if (listener.hasErrorTest) { | 2398 if (listener.hasErrorTest) { |
2399 let test = listener[_errorTest]; | 2399 let test = listener[_errorTest]; |
2400 try { | 2400 try { |
2401 matchesTest = dart.as(zone.runUnary(test, asyncError.error), c
ore.bool); | 2401 matchesTest = dart.as(zone.runUnary(test, asyncError.error), c
ore.bool); |
2402 } catch (e) { | 2402 } catch (e) { |
2403 let s = dart.stackTrace(e); | 2403 let s = dart.stackTrace(e); |
2404 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); | 2404 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); |
2405 listenerHasValue = false; | 2405 listenerHasValue = false; |
(...skipping 14 matching lines...) Expand all Loading... |
2420 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); | 2420 listenerValueOrError = core.identical(asyncError.error, e) ? a
syncError : new AsyncError(e, s); |
2421 listenerHasValue = false; | 2421 listenerHasValue = false; |
2422 return; | 2422 return; |
2423 } | 2423 } |
2424 | 2424 |
2425 listenerHasValue = true; | 2425 listenerHasValue = true; |
2426 } else { | 2426 } else { |
2427 listenerValueOrError = asyncError; | 2427 listenerValueOrError = asyncError; |
2428 listenerHasValue = false; | 2428 listenerHasValue = false; |
2429 } | 2429 } |
2430 } | 2430 }; |
2431 // Function handleWhenCompleteCallback: () → void | 2431 // Function handleWhenCompleteCallback: () → void |
2432 function handleWhenCompleteCallback() { | 2432 let handleWhenCompleteCallback = () => { |
2433 let completeResult = null; | 2433 let completeResult = null; |
2434 try { | 2434 try { |
2435 completeResult = zone.run(listener[_whenCompleteAction]); | 2435 completeResult = zone.run(listener[_whenCompleteAction]); |
2436 } catch (e) { | 2436 } catch (e) { |
2437 let s = dart.stackTrace(e); | 2437 let s = dart.stackTrace(e); |
2438 if (dart.notNull(hasError) && dart.notNull(core.identical(source
[_error].error, e))) { | 2438 if (dart.notNull(hasError) && dart.notNull(core.identical(source
[_error].error, e))) { |
2439 listenerValueOrError = source[_error]; | 2439 listenerValueOrError = source[_error]; |
2440 } else { | 2440 } else { |
2441 listenerValueOrError = new AsyncError(e, s); | 2441 listenerValueOrError = new AsyncError(e, s); |
2442 } | 2442 } |
(...skipping 12 matching lines...) Expand all Loading... |
2455 if (stackTrace === void 0) | 2455 if (stackTrace === void 0) |
2456 stackTrace = null; | 2456 stackTrace = null; |
2457 if (!dart.is(completeResult, _Future)) { | 2457 if (!dart.is(completeResult, _Future)) { |
2458 completeResult = new _Future(); | 2458 completeResult = new _Future(); |
2459 dart.dsend(completeResult, _setError, error, stackTrace); | 2459 dart.dsend(completeResult, _setError, error, stackTrace); |
2460 } | 2460 } |
2461 _Future._propagateToListeners(dart.as(completeResult, _Futur
e), new _FutureListener.chain(result)); | 2461 _Future._propagateToListeners(dart.as(completeResult, _Futur
e), new _FutureListener.chain(result)); |
2462 } | 2462 } |
2463 }); | 2463 }); |
2464 } | 2464 } |
2465 } | 2465 }; |
2466 if (!dart.notNull(hasError)) { | 2466 if (!dart.notNull(hasError)) { |
2467 if (listener.handlesValue) { | 2467 if (listener.handlesValue) { |
2468 listenerHasValue = handleValueCallback(); | 2468 listenerHasValue = handleValueCallback(); |
2469 } | 2469 } |
2470 } else { | 2470 } else { |
2471 handleError(); | 2471 handleError(); |
2472 } | 2472 } |
2473 if (listener.handlesComplete) { | 2473 if (listener.handlesComplete) { |
2474 handleWhenCompleteCallback(); | 2474 handleWhenCompleteCallback(); |
2475 } | 2475 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 static _initializeScheduleImmediate() { | 2645 static _initializeScheduleImmediate() { |
2646 _js_helper.requiresPreamble(); | 2646 _js_helper.requiresPreamble(); |
2647 if (self.scheduleImmediate != null) { | 2647 if (self.scheduleImmediate != null) { |
2648 return _AsyncRun._scheduleImmediateJsOverride; | 2648 return _AsyncRun._scheduleImmediateJsOverride; |
2649 } | 2649 } |
2650 if (dart.notNull(self.MutationObserver != null) && dart.notNull(self.docum
ent != null)) { | 2650 if (dart.notNull(self.MutationObserver != null) && dart.notNull(self.docum
ent != null)) { |
2651 let div = self.document.createElement("div"); | 2651 let div = self.document.createElement("div"); |
2652 let span = self.document.createElement("span"); | 2652 let span = self.document.createElement("span"); |
2653 let storedCallback = null; | 2653 let storedCallback = null; |
2654 // Function internalCallback: (dynamic) → dynamic | 2654 // Function internalCallback: (dynamic) → dynamic |
2655 function internalCallback(_) { | 2655 let internalCallback = _ => { |
2656 _isolate_helper.leaveJsAsync(); | 2656 _isolate_helper.leaveJsAsync(); |
2657 let f = storedCallback; | 2657 let f = storedCallback; |
2658 storedCallback = null; | 2658 storedCallback = null; |
2659 dart.dcall(f); | 2659 dart.dcall(f); |
2660 } | 2660 }; |
2661 ; | 2661 ; |
2662 let observer = new self.MutationObserver(_js_helper.convertDartClosureTo
JS(internalCallback, 1)); | 2662 let observer = new self.MutationObserver(_js_helper.convertDartClosureTo
JS(internalCallback, 1)); |
2663 observer.observe(div, {childList: true}); | 2663 observer.observe(div, {childList: true}); |
2664 return callback => { | 2664 return callback => { |
2665 dart.assert(storedCallback == null); | 2665 dart.assert(storedCallback == null); |
2666 _isolate_helper.enterJsAsync(); | 2666 _isolate_helper.enterJsAsync(); |
2667 storedCallback = callback; | 2667 storedCallback = callback; |
2668 div.firstChild ? div.removeChild(span) : div.appendChild(span); | 2668 div.firstChild ? div.removeChild(span) : div.appendChild(span); |
2669 }; | 2669 }; |
2670 } else if (self.setImmediate != null) { | 2670 } else if (self.setImmediate != null) { |
2671 return _AsyncRun._scheduleImmediateWithSetImmediate; | 2671 return _AsyncRun._scheduleImmediateWithSetImmediate; |
2672 } | 2672 } |
2673 return _AsyncRun._scheduleImmediateWithTimer; | 2673 return _AsyncRun._scheduleImmediateWithTimer; |
2674 } | 2674 } |
2675 static _scheduleImmediateJsOverride(callback) { | 2675 static _scheduleImmediateJsOverride(callback) { |
2676 // Function internalCallback: () → dynamic | 2676 // Function internalCallback: () → dynamic |
2677 function internalCallback() { | 2677 let internalCallback = () => { |
2678 _isolate_helper.leaveJsAsync(); | 2678 _isolate_helper.leaveJsAsync(); |
2679 callback(); | 2679 callback(); |
2680 } | 2680 }; |
2681 ; | 2681 ; |
2682 _isolate_helper.enterJsAsync(); | 2682 _isolate_helper.enterJsAsync(); |
2683 self.scheduleImmediate(_js_helper.convertDartClosureToJS(internalCallback,
0)); | 2683 self.scheduleImmediate(_js_helper.convertDartClosureToJS(internalCallback,
0)); |
2684 } | 2684 } |
2685 static _scheduleImmediateWithSetImmediate(callback) { | 2685 static _scheduleImmediateWithSetImmediate(callback) { |
2686 // Function internalCallback: () → dynamic | 2686 // Function internalCallback: () → dynamic |
2687 function internalCallback() { | 2687 let internalCallback = () => { |
2688 _isolate_helper.leaveJsAsync(); | 2688 _isolate_helper.leaveJsAsync(); |
2689 callback(); | 2689 callback(); |
2690 } | 2690 }; |
2691 ; | 2691 ; |
2692 _isolate_helper.enterJsAsync(); | 2692 _isolate_helper.enterJsAsync(); |
2693 self.setImmediate(_js_helper.convertDartClosureToJS(internalCallback, 0)); | 2693 self.setImmediate(_js_helper.convertDartClosureToJS(internalCallback, 0)); |
2694 } | 2694 } |
2695 static _scheduleImmediateWithTimer(callback) { | 2695 static _scheduleImmediateWithTimer(callback) { |
2696 Timer._createTimer(core.Duration.ZERO, callback); | 2696 Timer._createTimer(core.Duration.ZERO, callback); |
2697 } | 2697 } |
2698 } | 2698 } |
2699 dart.defineLazyProperties(_AsyncRun, { | 2699 dart.defineLazyProperties(_AsyncRun, { |
2700 get scheduleImmediateClosure() { | 2700 get scheduleImmediateClosure() { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3034 let s = dart.stackTrace(e); | 3034 let s = dart.stackTrace(e); |
3035 result = new _Future(); | 3035 result = new _Future(); |
3036 result[_asyncCompleteError](e, s); | 3036 result[_asyncCompleteError](e, s); |
3037 } | 3037 } |
3038 | 3038 |
3039 } else { | 3039 } else { |
3040 result = result.whenComplete(this[_onCancel]); | 3040 result = result.whenComplete(this[_onCancel]); |
3041 } | 3041 } |
3042 } | 3042 } |
3043 // Function complete: () → void | 3043 // Function complete: () → void |
3044 function complete() { | 3044 let complete = (() => { |
3045 if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_done
Future][_mayComplete])) { | 3045 if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_done
Future][_mayComplete])) { |
3046 this[_doneFuture][_asyncComplete](null); | 3046 this[_doneFuture][_asyncComplete](null); |
3047 } | 3047 } |
3048 } | 3048 }).bind(this); |
3049 if (result != null) { | 3049 if (result != null) { |
3050 result = result.whenComplete(complete); | 3050 result = result.whenComplete(complete); |
3051 } else { | 3051 } else { |
3052 complete(); | 3052 complete(); |
3053 } | 3053 } |
3054 return result; | 3054 return result; |
3055 } | 3055 } |
3056 [_recordPause](subscription) { | 3056 [_recordPause](subscription) { |
3057 dart.as(subscription, StreamSubscription$(T)); | 3057 dart.as(subscription, StreamSubscription$(T)); |
3058 if (this[_isAddingStream]) { | 3058 if (this[_isAddingStream]) { |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5360 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; | 5360 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; |
5361 exports.CreateTimerHandler = CreateTimerHandler; | 5361 exports.CreateTimerHandler = CreateTimerHandler; |
5362 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; | 5362 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; |
5363 exports.PrintHandler = PrintHandler; | 5363 exports.PrintHandler = PrintHandler; |
5364 exports.ForkHandler = ForkHandler; | 5364 exports.ForkHandler = ForkHandler; |
5365 exports.ZoneSpecification = ZoneSpecification; | 5365 exports.ZoneSpecification = ZoneSpecification; |
5366 exports.ZoneDelegate = ZoneDelegate; | 5366 exports.ZoneDelegate = ZoneDelegate; |
5367 exports.Zone = Zone; | 5367 exports.Zone = Zone; |
5368 exports.runZoned = runZoned; | 5368 exports.runZoned = runZoned; |
5369 })(async, core, _internal, _js_helper, _isolate_helper, collection); | 5369 })(async, core, _internal, _js_helper, _isolate_helper, collection); |
OLD | NEW |