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

Side by Side Diff: lib/src/typed/future.dart

Issue 1870543004: Add typed wrapper functions to delegate classes. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:async';
6
7 class TypeSafeFuture<T> implements Future<T> {
8 final Future _future;
9
10 TypeSafeFuture(this._future);
11
12 Stream<T> asStream() => _future.then((value) => value as T).asStream();
13
14 Future catchError(Function onError, {bool test(Object error)}) =>
15 _future.catchError(onError, test: test);
16
17 Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), {Function onError}) =>
18 _future.then((value) => onValue(value as T), onError: onError);
19
20 Future<T> whenComplete(action()) =>
21 new TypeSafeFuture<T>(_future.whenComplete(action));
22
23 Future<T> timeout(Duration timeLimit, {onTimeout()}) =>
24 new TypeSafeFuture<T>(_future.timeout(timeLimit, onTimeout: onTimeout));
25 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698