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

Side by Side Diff: lib/stream_channel.dart

Issue 1669953002: Provide more error-handling customization. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 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
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 'package:async/async.dart'; 7 import 'package:async/async.dart';
8 8
9 import 'src/guarantee_channel.dart'; 9 import 'src/guarantee_channel.dart';
10 import 'src/stream_channel_transformer.dart'; 10 import 'src/stream_channel_transformer.dart';
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 /// StreamChannel.withGuarantees] should be used instead. 71 /// StreamChannel.withGuarantees] should be used instead.
72 factory StreamChannel(Stream<T> stream, StreamSink<T> sink) => 72 factory StreamChannel(Stream<T> stream, StreamSink<T> sink) =>
73 new _StreamChannel<T>(stream, sink); 73 new _StreamChannel<T>(stream, sink);
74 74
75 /// Creates a new [StreamChannel] that communicates over [stream] and [sink]. 75 /// Creates a new [StreamChannel] that communicates over [stream] and [sink].
76 /// 76 ///
77 /// Unlike [new StreamChannel], this enforces the guarantees listed in the 77 /// Unlike [new StreamChannel], this enforces the guarantees listed in the
78 /// [StreamChannel] documentation. This makes it somewhat less efficient than 78 /// [StreamChannel] documentation. This makes it somewhat less efficient than
79 /// just wrapping a stream and a sink directly, so [new StreamChannel] should 79 /// just wrapping a stream and a sink directly, so [new StreamChannel] should
80 /// be used when the guarantees are provided natively. 80 /// be used when the guarantees are provided natively.
81 factory StreamChannel.withGuarantees(Stream<T> stream, StreamSink<T> sink) => 81 ///
82 new GuaranteeChannel(stream, sink); 82 /// If [allowSinkErrors] is `false`, errors are not allowed to be passed to
83 /// [sink]. If any are, the connection will close and the error will be
84 /// forwarded to [Sink.done].
85 factory StreamChannel.withGuarantees(Stream<T> stream, StreamSink<T> sink,
86 {bool allowSinkErrors: true}) =>
87 new GuaranteeChannel(stream, sink, allowSinkErrors: allowSinkErrors);
83 88
84 /// Connects [this] to [other], so that any values emitted by either are sent 89 /// Connects [this] to [other], so that any values emitted by either are sent
85 /// directly to the other. 90 /// directly to the other.
86 void pipe(StreamChannel<T> other); 91 void pipe(StreamChannel<T> other);
87 92
88 /// Transforms [this] using [transformer]. 93 /// Transforms [this] using [transformer].
89 /// 94 ///
90 /// This is identical to calling `transformer.bind(channel)`. 95 /// This is identical to calling `transformer.bind(channel)`.
91 StreamChannel transform(StreamChannelTransformer<T, dynamic> transformer); 96 StreamChannel transform(StreamChannelTransformer<T, dynamic> transformer);
92 97
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 138
134 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer) => 139 StreamChannel<T> transformSink(StreamSinkTransformer<T, T> transformer) =>
135 changeSink(transformer.bind); 140 changeSink(transformer.bind);
136 141
137 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)) => 142 StreamChannel<T> changeStream(Stream<T> change(Stream<T> stream)) =>
138 new StreamChannel(change(stream), sink); 143 new StreamChannel(change(stream), sink);
139 144
140 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)) => 145 StreamChannel<T> changeSink(StreamSink<T> change(StreamSink<T> sink)) =>
141 new StreamChannel(stream, change(sink)); 146 new StreamChannel(stream, change(sink));
142 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698