Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing error from the source stream #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/src/decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ class EventSourceDecoder implements StreamTransformer<List<int>, Event> {
// This stream will receive chunks of data that is not necessarily a
// single event. So we build events on the fly and broadcast the event as
// soon as we encounter a double newline, then we start a new one.
stream
.transform(new Utf8Decoder())
.transform(new LineSplitter())
.listen((String line) {
stream.transform(new Utf8Decoder()).transform(new LineSplitter()).listen(
(String line) {
if (line.isEmpty) {
// event is done
// strip ending newline from data
Expand Down Expand Up @@ -60,6 +58,8 @@ class EventSourceDecoder implements StreamTransformer<List<int>, Event> {
retryIndicator?.call(new Duration(milliseconds: int.parse(value)));
break;
}
}, onError: (error) {
controller.addError(error);
});
});
return controller.stream;
Expand Down
Loading