Line data Source code
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 : /// Simple delegating wrapper around a [Stream]. 8 : /// 9 : /// Subclasses can override individual methods, or use this to expose only the 10 : /// [Stream] methods of a subclass. 11 : /// 12 : /// Note that this is identical to [StreamView] in `dart:async`. It's provided 13 : /// under this name for consistency with other `Delegating*` classes. 14 : class DelegatingStream<T> extends StreamView<T> { 15 0 : DelegatingStream(Stream<T> stream) : super(stream); 16 : 17 : /// Creates a wrapper which throws if [stream]'s events aren't instances of 18 : /// `T`. 19 : /// 20 : /// This soundly converts a [Stream] to a `Stream<T>`, regardless of its 21 : /// original generic type, by asserting that its events are instances of `T` 22 : /// whenever they're provided. If they're not, the stream throws a 23 : /// [TypeError]. 24 0 : @Deprecated('Use stream.cast instead') 25 0 : static Stream<T> typed<T>(Stream stream) => stream.cast(); 26 : }