sse static method
Implementation
static dv.Response sse(Stream<String> events,
{int status = 200, Map<String, String>? headers}) {
final stream = events
.map((e) => 'data: ${e.replaceAll('\n', '\ndata: ')}\n\n')
.map(utf8.encode);
return dv.Response(status,
headers: dv.Headers({
'content-type': 'text/event-stream; charset=utf-8',
'cache-control': 'no-cache',
'connection': 'keep-alive',
...?headers,
}),
body: stream);
}