sse method
Implementation
Future sse(
String api,
Map<String, dynamic> map,
eventHandler, {
Function? onError,
void Function()? onDone,
}) async {
var uri = Uri(
scheme: _scheme,
host: _host,
path: _pathRoot + api,
queryParameters: _queryMap,
);
var postBody = json.encode(map);
var es = await EventSource.connect(
uri,
headers: {"content-type": "application/json"},
method: "POST",
body: postBody,
);
es.listen((event) {
eventHandler(event);
}, onError: (e) {
log(e.toString());
if (onError != null) {
onError(e);
}
});
}