| Index: packages/async/lib/src/result/value.dart
|
| diff --git a/packages/async/lib/src/result/value.dart b/packages/async/lib/src/result/value.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..39fa04818da6e6262452858c78afbc3d8f1421d7
|
| --- /dev/null
|
| +++ b/packages/async/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<T> 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);
|
| +}
|
|
|