OLD | NEW |
1 dart_library.library('dart/async', null, /* Imports */[ | 1 dart_library.library('dart/async', null, /* Imports */[ |
2 "dart_runtime/dart", | 2 "dart_runtime/dart", |
3 'dart/core', | 3 'dart/core', |
4 'dart/_internal', | 4 'dart/_internal', |
5 'dart/collection' | 5 'dart/collection' |
6 ], /* Lazy imports */[ | 6 ], /* Lazy imports */[ |
7 'dart/_isolate_helper' | 7 'dart/_isolate_helper' |
8 ], function(exports, dart, core, _internal, collection, _isolate_helper) { | 8 ], function(exports, dart, core, _internal, collection, _isolate_helper) { |
9 'use strict'; | 9 'use strict'; |
10 let dartx = dart.dartx; | 10 let dartx = dart.dartx; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 dart.as(convert, dart.functionType(dart.dynamic, [T])); | 157 dart.as(convert, dart.functionType(dart.dynamic, [T])); |
158 return new (_MapStream$(T, dart.dynamic))(this, convert); | 158 return new (_MapStream$(T, dart.dynamic))(this, convert); |
159 } | 159 } |
160 asyncMap(convert) { | 160 asyncMap(convert) { |
161 dart.as(convert, dart.functionType(dart.dynamic, [T])); | 161 dart.as(convert, dart.functionType(dart.dynamic, [T])); |
162 let controller = null; | 162 let controller = null; |
163 let subscription = null; | 163 let subscription = null; |
164 let onListen = (function() { | 164 let onListen = (function() { |
165 let add = dart.bind(controller, 'add'); | 165 let add = dart.bind(controller, 'add'); |
166 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 166 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
167 let eventSink = controller; | 167 let eventSink = dart.as(controller, _EventSink$(T)); |
168 let addError = eventSink[_addError]; | 168 let addError = dart.bind(eventSink, _addError); |
169 subscription = this.listen(dart.fn(event => { | 169 subscription = this.listen(dart.fn(event => { |
170 dart.as(event, T); | 170 dart.as(event, T); |
171 let newValue = null; | 171 let newValue = null; |
172 try { | 172 try { |
173 newValue = convert(event); | 173 newValue = convert(event); |
174 } catch (e) { | 174 } catch (e) { |
175 let s = dart.stackTrace(e); | 175 let s = dart.stackTrace(e); |
176 controller.addError(e, s); | 176 controller.addError(e, s); |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 if (dart.is(newValue, Future)) { | 180 if (dart.is(newValue, Future)) { |
181 subscription.pause(); | 181 subscription.pause(); |
182 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}),
'whenComplete', dart.bind(subscription, 'resume')); | 182 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}),
'whenComplete', dart.bind(subscription, 'resume')); |
183 } else { | 183 } else { |
184 controller.add(newValue); | 184 controller.add(newValue); |
185 } | 185 } |
186 }, dart.dynamic, [T]), {onError: dart.as(addError, core.Function), onD
one: dart.bind(controller, 'close')}); | 186 }, dart.dynamic, [T]), {onError: addError, onDone: dart.bind(controlle
r, 'close')}); |
187 }).bind(this); | 187 }).bind(this); |
188 dart.fn(onListen, dart.void, []); | 188 dart.fn(onListen, dart.void, []); |
189 if (dart.notNull(this.isBroadcast)) { | 189 if (dart.notNull(this.isBroadcast)) { |
190 controller = StreamController.broadcast({onListen: onListen, onCancel:
dart.fn(() => { | 190 controller = StreamController.broadcast({onListen: onListen, onCancel:
dart.fn(() => { |
191 subscription.cancel(); | 191 subscription.cancel(); |
192 }), sync: true}); | 192 }), sync: true}); |
193 } else { | 193 } else { |
194 controller = StreamController.new({onListen: onListen, onPause: dart.f
n(() => { | 194 controller = StreamController.new({onListen: onListen, onPause: dart.f
n(() => { |
195 subscription.pause(); | 195 subscription.pause(); |
196 }), onResume: dart.fn(() => { | 196 }), onResume: dart.fn(() => { |
197 subscription.resume(); | 197 subscription.resume(); |
198 }), onCancel: dart.fn(() => { | 198 }), onCancel: dart.fn(() => { |
199 subscription.cancel(); | 199 subscription.cancel(); |
200 }), sync: true}); | 200 }), sync: true}); |
201 } | 201 } |
202 return controller.stream; | 202 return controller.stream; |
203 } | 203 } |
204 asyncExpand(convert) { | 204 asyncExpand(convert) { |
205 dart.as(convert, dart.functionType(Stream$(), [T])); | 205 dart.as(convert, dart.functionType(Stream$(), [T])); |
206 let controller = null; | 206 let controller = null; |
207 let subscription = null; | 207 let subscription = null; |
208 let onListen = (function() { | 208 let onListen = (function() { |
209 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 209 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
210 let eventSink = controller; | 210 let eventSink = dart.as(controller, _EventSink$(T)); |
211 subscription = this.listen(dart.fn(event => { | 211 subscription = this.listen(dart.fn(event => { |
212 dart.as(event, T); | 212 dart.as(event, T); |
213 let newStream = null; | 213 let newStream = null; |
214 try { | 214 try { |
215 newStream = convert(event); | 215 newStream = convert(event); |
216 } catch (e) { | 216 } catch (e) { |
217 let s = dart.stackTrace(e); | 217 let s = dart.stackTrace(e); |
218 controller.addError(e, s); | 218 controller.addError(e, s); |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
222 if (newStream != null) { | 222 if (newStream != null) { |
223 subscription.pause(); | 223 subscription.pause(); |
224 controller.addStream(newStream).whenComplete(dart.bind(subscriptio
n, 'resume')); | 224 controller.addStream(newStream).whenComplete(dart.bind(subscriptio
n, 'resume')); |
225 } | 225 } |
226 }, dart.dynamic, [T]), {onError: dart.as(eventSink[_addError], core.Fu
nction), onDone: dart.bind(controller, 'close')}); | 226 }, dart.dynamic, [T]), {onError: dart.bind(eventSink, _addError), onDo
ne: dart.bind(controller, 'close')}); |
227 }).bind(this); | 227 }).bind(this); |
228 dart.fn(onListen, dart.void, []); | 228 dart.fn(onListen, dart.void, []); |
229 if (dart.notNull(this.isBroadcast)) { | 229 if (dart.notNull(this.isBroadcast)) { |
230 controller = StreamController.broadcast({onListen: onListen, onCancel:
dart.fn(() => { | 230 controller = StreamController.broadcast({onListen: onListen, onCancel:
dart.fn(() => { |
231 subscription.cancel(); | 231 subscription.cancel(); |
232 }), sync: true}); | 232 }), sync: true}); |
233 } else { | 233 } else { |
234 controller = StreamController.new({onListen: onListen, onPause: dart.f
n(() => { | 234 controller = StreamController.new({onListen: onListen, onPause: dart.f
n(() => { |
235 subscription.pause(); | 235 subscription.pause(); |
236 }), onResume: dart.fn(() => { | 236 }), onResume: dart.fn(() => { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 function onData(event) { | 667 function onData(event) { |
668 dart.as(event, T); | 668 dart.as(event, T); |
669 timer.cancel(); | 669 timer.cancel(); |
670 controller.add(event); | 670 controller.add(event); |
671 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType17)); | 671 timer = zone.createTimer(timeLimit, dart.as(timeout, __CastType17)); |
672 } | 672 } |
673 dart.fn(onData, dart.void, [T]); | 673 dart.fn(onData, dart.void, [T]); |
674 function onError(error, stackTrace) { | 674 function onError(error, stackTrace) { |
675 timer.cancel(); | 675 timer.cancel(); |
676 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); | 676 dart.assert(dart.is(controller, _StreamController) || dart.is(controll
er, _BroadcastStreamController)); |
677 let eventSink = controller; | 677 let eventSink = dart.as(controller, _EventSink$(T)); |
678 dart.dcall(eventSink[_addError], error, stackTrace); | 678 eventSink[_addError](error, stackTrace); |
679 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); | 679 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType
(dart.void, []))); |
680 } | 680 } |
681 dart.fn(onError, dart.void, [dart.dynamic, core.StackTrace]); | 681 dart.fn(onError, dart.void, [dart.dynamic, core.StackTrace]); |
682 function onDone() { | 682 function onDone() { |
683 timer.cancel(); | 683 timer.cancel(); |
684 controller.close(); | 684 controller.close(); |
685 } | 685 } |
686 dart.fn(onDone, dart.void, []); | 686 dart.fn(onDone, dart.void, []); |
687 let onListen = (function() { | 687 let onListen = (function() { |
688 zone = Zone.current; | 688 zone = Zone.current; |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 onDone = _nullDoneHandler; | 1386 onDone = _nullDoneHandler; |
1387 return new (_DoneStreamSubscription$(T))(onDone); | 1387 return new (_DoneStreamSubscription$(T))(onDone); |
1388 } | 1388 } |
1389 let subscription = new (_BroadcastSubscription$(T))(this, onData, onErro
r, onDone, cancelOnError); | 1389 let subscription = new (_BroadcastSubscription$(T))(this, onData, onErro
r, onDone, cancelOnError); |
1390 this[_addListener](dart.as(subscription, _BroadcastSubscription$(T))); | 1390 this[_addListener](dart.as(subscription, _BroadcastSubscription$(T))); |
1391 if (dart.notNull(core.identical(this[_next], this[_previous]))) { | 1391 if (dart.notNull(core.identical(this[_next], this[_previous]))) { |
1392 _runGuarded(this[_onListen]); | 1392 _runGuarded(this[_onListen]); |
1393 } | 1393 } |
1394 return dart.as(subscription, StreamSubscription$(T)); | 1394 return dart.as(subscription, StreamSubscription$(T)); |
1395 } | 1395 } |
1396 [_recordCancel](subscription) { | 1396 [_recordCancel](sub) { |
1397 dart.as(subscription, StreamSubscription$(T)); | 1397 dart.as(sub, StreamSubscription$(T)); |
| 1398 let subscription = dart.as(sub, _BroadcastSubscription$(T)); |
1398 if (dart.notNull(core.identical(subscription[_next], subscription))) | 1399 if (dart.notNull(core.identical(subscription[_next], subscription))) |
1399 return null; | 1400 return null; |
1400 dart.assert(!dart.notNull(core.identical(subscription[_next], subscripti
on))); | 1401 dart.assert(!dart.notNull(core.identical(subscription[_next], subscripti
on))); |
1401 if (dart.notNull(dart.as(subscription[_isFiring], core.bool))) { | 1402 if (dart.notNull(subscription[_isFiring])) { |
1402 dart.dcall(subscription[_setRemoveAfterFiring]); | 1403 subscription[_setRemoveAfterFiring](); |
1403 } else { | 1404 } else { |
1404 dart.assert(!dart.notNull(core.identical(subscription[_next], subscrip
tion))); | 1405 dart.assert(!dart.notNull(core.identical(subscription[_next], subscrip
tion))); |
1405 this[_removeListener](dart.as(subscription, _BroadcastSubscription$(T)
)); | 1406 this[_removeListener](subscription); |
1406 if (!dart.notNull(this[_isFiring]) && dart.notNull(this[_isEmpty])) { | 1407 if (!dart.notNull(this[_isFiring]) && dart.notNull(this[_isEmpty])) { |
1407 this[_callOnCancel](); | 1408 this[_callOnCancel](); |
1408 } | 1409 } |
1409 } | 1410 } |
1410 return null; | 1411 return null; |
1411 } | 1412 } |
1412 [_recordPause](subscription) { | 1413 [_recordPause](subscription) { |
1413 dart.as(subscription, StreamSubscription$(T)); | 1414 dart.as(subscription, StreamSubscription$(T)); |
1414 } | 1415 } |
1415 [_recordResume](subscription) { | 1416 [_recordResume](subscription) { |
(...skipping 4497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5913 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; | 5914 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; |
5914 exports.CreateTimerHandler = CreateTimerHandler; | 5915 exports.CreateTimerHandler = CreateTimerHandler; |
5915 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; | 5916 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; |
5916 exports.PrintHandler = PrintHandler; | 5917 exports.PrintHandler = PrintHandler; |
5917 exports.ForkHandler = ForkHandler; | 5918 exports.ForkHandler = ForkHandler; |
5918 exports.ZoneSpecification = ZoneSpecification; | 5919 exports.ZoneSpecification = ZoneSpecification; |
5919 exports.ZoneDelegate = ZoneDelegate; | 5920 exports.ZoneDelegate = ZoneDelegate; |
5920 exports.Zone = Zone; | 5921 exports.Zone = Zone; |
5921 exports.runZoned = runZoned; | 5922 exports.runZoned = runZoned; |
5922 }); | 5923 }); |
OLD | NEW |