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. |