w3c_event_source 1.2.2 copy "w3c_event_source: ^1.2.2" to clipboard
w3c_event_source: ^1.2.2 copied to clipboard

outdated

W3C EventSource client implementation for Dart / Flutter, to communicate with server-sent event endpoints.

w3c_event_source #

pub package build status

W3C EventSource client implementation for Dart / Flutter.

This package depends on dart:io, so it is not usable on the Web. If you'd like to contribute a wrapper around dart:html's EventSource, feel free!

Install #

Add to your pubspec.yaml:

dependencies:
  w3c_event_source: ^1.2.2

Usage #

import 'dart:async';
import 'package:w3c_event_source/event_source.dart';

final events = EventSource(Uri.parse('http://api.example.com/ssedemo.php'));

// Listening on the `events` stream will open a connection.
final subscription = events.events.listen((MessageEvent message) {
  print('${message.name}: ${message.data}');
});

Timer(Duration(seconds: 30), () {
  // Canceling the subscription closes the connection.
  subscription.cancel();
});

License #

MIT

5
likes
0
pub points
58%
popularity

Publisher

unverified uploader

W3C EventSource client implementation for Dart / Flutter, to communicate with server-sent event endpoints.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on w3c_event_source