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

Unified Diff: lib/src/result/value.dart

Issue 1777453002: Modernize the package's style. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Created 4 years, 9 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
Index: lib/src/result/value.dart
diff --git a/lib/src/result/value.dart b/lib/src/result/value.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f065ab670c49549259cb2552651e42d0e6c6ccfd
--- /dev/null
+++ b/lib/src/result/value.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import '../result.dart';
+import 'error.dart';
+
+/// A result representing a returned value.
+class ValueResult<T> implements Result<T> {
+ final T value;
+
+ bool get isValue => true;
+ bool get isError => false;
+ ValueResult<T> get asValue => this;
+ ErrorResult get asError => null;
+
+ ValueResult(this.value);
+
+ void complete(Completer<T> completer) {
+ completer.complete(value);
+ }
+
+ void addTo(EventSink<T> sink) {
+ sink.add(value);
+ }
+
+ Future<T> get asFuture => new Future.value(value);
+}

Powered by Google App Engine
This is Rietveld 408576698