StreamTransformer.fromHandlers factory constructor

StreamTransformer.fromHandlers({void handleData(S data, EventSink<T> sink), void handleError(Object error, StackTrace stackTrace, EventSink<T> sink), void handleDone(EventSink<T> sink) })

Creates a StreamTransformer that delegates events to the given functions.

Example use of a duplicating transformer:

stringStream.transform(new StreamTransformer<String, String>.fromHandlers(
    handleData: (String value, EventSink<String> sink) {
      sink.add(value);
      sink.add(value);  // Duplicate the incoming events.
    }));

Source

factory StreamTransformer.fromHandlers(
    {void handleData(S data, EventSink<T> sink),
    void handleError(Object error, StackTrace stackTrace, EventSink<T> sink),
    void handleDone(EventSink<T> sink)}) = _StreamHandlerTransformer<S, T>;

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-async/StreamTransformer/StreamTransformer.fromHandlers.html