Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Unified Diff: packages/when/lib/when.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/when/example/read_json_file.dart ('k') | packages/when/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/when/lib/when.dart
diff --git a/packages/when/lib/when.dart b/packages/when/lib/when.dart
deleted file mode 100755
index 703ecc20982b5345d70aa4ccfe8c5d3df161a86d..0000000000000000000000000000000000000000
--- a/packages/when/lib/when.dart
+++ /dev/null
@@ -1,68 +0,0 @@
-
-library when;
-
-import 'dart:async';
-
-/// Registers callbacks on the result of a [callback], which may or may not be
-/// a [Future].
-///
-/// If [callback] returns a future, any of [onSuccess], [onError], or
-/// [onComplete] that are provided are registered on the future,
-/// and the resulting future is returned.
-///
-/// Otherwise, if [callback] did not throw, if [onSuccess] is provided, it is
-/// called with the with the result of [callback], and the return value of
-/// [onSuccess] is captured.
-///
-/// Otherwise, if [onError] was provided, it is called. It can take either
-/// just an error, or a stack trace as well. If [onError] was not provided,
-/// the error is not caught.
-///
-/// [onComplete] is then called synchronously.
-///
-/// The captured value is then returned.
-when(callback, {onSuccess(result), onError, onComplete}) {
- var result, hasResult = false;
-
- try {
- result = callback();
- hasResult = true;
- } catch (e, s) {
- if (onError != null) {
- if (onError is _Unary) {
- onError(e);
- } else if (onError is _Binary) {
- onError(e, s);
- } else {
- throw new ArgumentError(
- '"onError" must accept 1 or 2 arguments: $onError');
- }
- } else {
- rethrow;
- }
- } finally {
- if (result is Future) {
- if (onSuccess != null) {
- result = result.then(onSuccess);
- }
- if (onError != null) {
- result = result.catchError(onError);
- }
- if (onComplete != null) {
- result = result.whenComplete(onComplete);
- }
- } else {
- if (hasResult) {
- if (onSuccess != null) {
- result = onSuccess(result);
- }
- }
- if (onComplete != null) onComplete();
- }
- }
-
- return result;
-}
-
-typedef _Unary(x);
-typedef _Binary(x, y);
« no previous file with comments | « packages/when/example/read_json_file.dart ('k') | packages/when/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698