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

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

Issue 1870543004: Add typed wrapper functions to delegate classes. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: 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 TypeSafeStreamSubscription<T> implements StreamSubscription<T> {
8 final StreamSubscription _subscription;
9
10 bool get isPaused => _subscription.isPaused;
11
12 TypeSafeStreamSubscription(this._subscription);
13
14 void onData(void handleData(T data)) {
15 _subscription.onData((data) => handleData(data as T));
16 }
17
18 void onError(Function handleError) {
19 _subscription.onError(handleError);
20 }
21
22 void onDone(void handleDone()) {
23 _subscription.onDone(handleDone);
24 }
25
26 void pause([Future resumeFuture]) {
27 _subscription.pause(resumeFuture);
28 }
29
30 void resume() {
31 _subscription.resume();
32 }
33
34 Future cancel() => _subscription.cancel();
35 Future asFuture([futureValue]) => _subscription.asFuture(futureValue);
Lasse Reichstein Nielsen 2016/04/08 09:20:29 Could be Future<S> asFuture<S>([S futureValue]) i
nweiz 2016/04/11 20:26:16 Strong mode won't let us add typing that's not the
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698