HtmlSseClient.connect constructor

HtmlSseClient.connect(
  1. Uri uri, {
  2. bool withCredentials = false,
})

Implementation

factory HtmlSseClient.connect(Uri uri, {bool withCredentials = false}) {
  final incomingController = StreamController<String?>();
  final eventSource =
      EventSource(uri.toString(), withCredentials: withCredentials);

  eventSource.addEventListener('message', (Event message) {
    incomingController.add((message as MessageEvent).data as String?);
  });

  return HtmlSseClient(incomingController.stream);
}