start method
Starts listening to the stream.
Messages are sent through the provided sendMessage callback.
Implementation
void start(void Function(Msg) sendMessage) {
_subscription = stream.listen(
(data) {
final msg = onData(data);
if (msg != null) sendMessage(msg);
},
onError: (Object error, StackTrace stack) {
if (onError != null) {
final msg = onError!(error, stack);
if (msg != null) sendMessage(msg);
}
},
onDone: () {
if (onDone != null) {
final msg = onDone!();
if (msg != null) sendMessage(msg);
}
},
);
}