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

Unified Diff: sdk/lib/async/stream_transformers.dart

Issue 2762953003: More minor type improvements in dart:async. (Closed)
Patch Set: More fixes. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/async/stream_pipe.dart ('k') | sdk/lib/async/zone.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_transformers.dart
diff --git a/sdk/lib/async/stream_transformers.dart b/sdk/lib/async/stream_transformers.dart
index c4cbf04332b7403cb7b1fd6d0964b0b02bf7951f..bfc83d6b58b4befbe215bd641956492567b85380 100644
--- a/sdk/lib/async/stream_transformers.dart
+++ b/sdk/lib/async/stream_transformers.dart
@@ -215,15 +215,27 @@ class _HandlerEventSink<S, T> implements EventSink<S> {
this._handleData, this._handleError, this._handleDone, this._sink);
void add(S data) {
- _handleData(data, _sink);
+ if (_handleData != null) {
+ _handleData(data, _sink);
+ } else {
+ _sink.add(data as T);
+ }
}
void addError(Object error, [StackTrace stackTrace]) {
- _handleError(error, stackTrace, _sink);
+ if (_handleError != null) {
+ _handleError(error, stackTrace, _sink);
+ } else {
+ _sink.addError(error, stackTrace);
+ }
}
void close() {
- _handleDone(_sink);
+ if (_handleDone != null) {
+ _handleDone(_sink);
+ } else {
+ _sink.close();
+ }
}
}
@@ -238,9 +250,6 @@ class _StreamHandlerTransformer<S, T> extends _StreamSinkTransformer<S, T> {
void handleError(Object error, StackTrace stackTrace, EventSink<T> sink),
void handleDone(EventSink<T> sink)})
: super((EventSink<T> outputSink) {
- if (handleData == null) handleData = _defaultHandleData;
- if (handleError == null) handleError = _defaultHandleError;
- if (handleDone == null) handleDone = _defaultHandleDone;
return new _HandlerEventSink<S, T>(
handleData, handleError, handleDone, outputSink);
});
@@ -248,22 +257,6 @@ class _StreamHandlerTransformer<S, T> extends _StreamSinkTransformer<S, T> {
Stream<T> bind(Stream<S> stream) {
return super.bind(stream);
}
-
- /** Default data handler forwards all data. */
- static void _defaultHandleData(var data, EventSink sink) {
- sink.add(data);
- }
-
- /** Default error handler forwards all errors. */
- static void _defaultHandleError(
- error, StackTrace stackTrace, EventSink sink) {
- sink.addError(error, stackTrace);
- }
-
- /** Default done handler forwards done. */
- static void _defaultHandleDone(EventSink sink) {
- sink.close();
- }
}
/// A closure mapping a stream and cancelOnError to a StreamSubscription.
« no previous file with comments | « sdk/lib/async/stream_pipe.dart ('k') | sdk/lib/async/zone.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698