| 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 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** Runs user code and takes actions depending on success or failure. */ | 7 /** Runs user code and takes actions depending on success or failure. */ |
| 8 _runUserCode(userCode(), | 8 _runUserCode(userCode(), |
| 9 onSuccess(value), | 9 onSuccess(value), |
| 10 onError(error, StackTrace stackTrace)) { | 10 onError(error, StackTrace stackTrace)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 /** Helper function to cancel a subscription and wait for the potential future, | 25 /** Helper function to cancel a subscription and wait for the potential future, |
| 26 before completing with an error. */ | 26 before completing with an error. */ |
| 27 void _cancelAndError(StreamSubscription subscription, | 27 void _cancelAndError(StreamSubscription subscription, |
| 28 _Future future, | 28 _Future future, |
| 29 error, | 29 error, |
| 30 StackTrace stackTrace) { | 30 StackTrace stackTrace) { |
| 31 var cancelFuture = subscription.cancel(); | 31 var cancelFuture = subscription.cancel(); |
| 32 if (cancelFuture is Future) { | 32 if (cancelFuture is Future && !identical(cancelFuture, Future._nullFuture)) { |
| 33 cancelFuture.whenComplete(() => future._completeError(error, stackTrace)); | 33 cancelFuture.whenComplete(() => future._completeError(error, stackTrace)); |
| 34 } else { | 34 } else { |
| 35 future._completeError(error, stackTrace); | 35 future._completeError(error, stackTrace); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 | 38 |
| 39 void _cancelAndErrorWithReplacement(StreamSubscription subscription, | 39 void _cancelAndErrorWithReplacement(StreamSubscription subscription, |
| 40 _Future future, | 40 _Future future, |
| 41 error, StackTrace stackTrace) { | 41 error, StackTrace stackTrace) { |
| 42 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); | 42 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 StreamSubscription subscription, _Future future) { | 54 StreamSubscription subscription, _Future future) { |
| 55 return (error, StackTrace stackTrace) { | 55 return (error, StackTrace stackTrace) { |
| 56 _cancelAndError(subscription, future, error, stackTrace); | 56 _cancelAndError(subscription, future, error, stackTrace); |
| 57 }; | 57 }; |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** Helper function to cancel a subscription and wait for the potential future, | 60 /** Helper function to cancel a subscription and wait for the potential future, |
| 61 before completing with a value. */ | 61 before completing with a value. */ |
| 62 void _cancelAndValue(StreamSubscription subscription, _Future future, value) { | 62 void _cancelAndValue(StreamSubscription subscription, _Future future, value) { |
| 63 var cancelFuture = subscription.cancel(); | 63 var cancelFuture = subscription.cancel(); |
| 64 if (cancelFuture is Future) { | 64 if (cancelFuture is Future && !identical(cancelFuture, Future._nullFuture)) { |
| 65 cancelFuture.whenComplete(() => future._complete(value)); | 65 cancelFuture.whenComplete(() => future._complete(value)); |
| 66 } else { | 66 } else { |
| 67 future._complete(value); | 67 future._complete(value); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * A [Stream] that forwards subscriptions to another stream. | 73 * A [Stream] that forwards subscriptions to another stream. |
| 74 * | 74 * |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 _addErrorWithReplacement(sink, e, s); | 486 _addErrorWithReplacement(sink, e, s); |
| 487 return null; | 487 return null; |
| 488 } | 488 } |
| 489 if (!isEqual) { | 489 if (!isEqual) { |
| 490 sink._add(inputEvent); | 490 sink._add(inputEvent); |
| 491 _previous = inputEvent; | 491 _previous = inputEvent; |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 } | 495 } |
| OLD | NEW |