OLD | NEW |
---|---|
(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 import '../typed/stream.dart'; | |
8 | |
9 /// Simple delegating wrapper around a [Stream]. | |
10 /// | |
11 /// Subclasses can override individual methods, or use this to expose only the | |
12 /// [Stream] methods of a subclass. | |
13 /// | |
14 /// Note that this is identical to [StreamView] in `dart:async`. It's provided | |
15 /// under this name for consistency with other `Delegating*` classes. | |
16 class DelegatingStream<T> extends StreamView<T> { | |
17 DelegatingStream(Stream<T> stream) : super(stream); | |
18 | |
19 /// Creates a wrapper that asserts the types of the events emitted by | |
20 /// [stream]. | |
21 /// | |
22 /// This soundly converts a [Stream] without a generic type to a `Stream<T>` | |
23 /// by asserting that its events are instances of `T` whenever they're | |
24 /// accessed. If they're not, it throws a [CastError]. | |
Lasse Reichstein Nielsen
2016/04/08 09:20:29
Same comments as for Future.
nweiz
2016/04/11 20:26:16
Done.
| |
25 static Stream/*<T>*/ typed/*<T>*/(Stream stream) => | |
26 stream is Stream/*<T>*/ ? stream : new TypeSafeStream/*<T>*/(stream); | |
27 } | |
OLD | NEW |