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

Side by Side Diff: lib/src/typed_stream_transformer.dart

Issue 2660333005: Change generic comment syntax to real generic syntax. (Closed)
Patch Set: Update version. Created 3 years, 10 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
« no previous file with comments | « lib/src/typed/stream_subscription.dart ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'delegate/stream.dart'; 7 import 'delegate/stream.dart';
8 8
9 /// Creates a wrapper that coerces the type of [transformer]. 9 /// Creates a wrapper that coerces the type of [transformer].
10 /// 10 ///
11 /// This soundly converts a [StreamTransformer] to a `StreamTransformer<S, T>`, 11 /// This soundly converts a [StreamTransformer] to a `StreamTransformer<S, T>`,
12 /// regardless of its original generic type, by asserting that the events 12 /// regardless of its original generic type, by asserting that the events
13 /// emitted by the transformed stream are instances of `T` whenever they're 13 /// emitted by the transformed stream are instances of `T` whenever they're
14 /// provided. If they're not, the stream throws a [CastError]. 14 /// provided. If they're not, the stream throws a [CastError].
15 StreamTransformer/*<S, T>*/ typedStreamTransformer/*<S, T>*/( 15 StreamTransformer<S, T> typedStreamTransformer<S, T>(
16 StreamTransformer transformer) => 16 StreamTransformer transformer) =>
17 transformer is StreamTransformer/*<S, T>*/ 17 transformer is StreamTransformer<S, T>
18 ? transformer 18 ? transformer
19 : new _TypeSafeStreamTransformer(transformer); 19 : new _TypeSafeStreamTransformer(transformer);
20 20
21 /// A wrapper that coerces the type of the stream returned by an inner 21 /// A wrapper that coerces the type of the stream returned by an inner
22 /// transformer. 22 /// transformer.
23 class _TypeSafeStreamTransformer<S, T> implements StreamTransformer<S, T> { 23 class _TypeSafeStreamTransformer<S, T> implements StreamTransformer<S, T> {
24 final StreamTransformer _inner; 24 final StreamTransformer _inner;
25 25
26 _TypeSafeStreamTransformer(this._inner); 26 _TypeSafeStreamTransformer(this._inner);
27 27
28 Stream<T> bind(Stream<S> stream) => 28 Stream<T> bind(Stream<S> stream) =>
29 DelegatingStream.typed(_inner.bind(stream)); 29 DelegatingStream.typed(_inner.bind(stream));
30 } 30 }
OLDNEW
« no previous file with comments | « lib/src/typed/stream_subscription.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698