Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goto-bus-stop/dart-event-source
W3C EventSource client implementation for Dart
https://github.com/goto-bus-stop/dart-event-source
dart event-source event-source-client flutter
Last synced: 27 days ago
JSON representation
W3C EventSource client implementation for Dart
- Host: GitHub
- URL: https://github.com/goto-bus-stop/dart-event-source
- Owner: goto-bus-stop
- License: mit
- Created: 2018-10-13T10:59:48.000Z (about 6 years ago)
- Default Branch: default
- Last Pushed: 2020-06-20T20:41:36.000Z (over 4 years ago)
- Last Synced: 2024-10-05T16:26:26.425Z (about 1 month ago)
- Topics: dart, event-source, event-source-client, flutter
- Language: Dart
- Size: 32.2 KB
- Stars: 9
- Watchers: 3
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# w3c_event_source
[![pub package][0]][1]
[![build status][2]][3][0]: https://img.shields.io/pub/v/w3c_event_source.svg?style=flat-square
[1]: https://pub.dartlang.org/packages/w3c_event_source
[2]: https://img.shields.io/travis/com/goto-bus-stop/dart-event-source/default.svg?style=flat-square
[3]: https://travis-ci.com/goto-bus-stop/dart-event-sourceW3C [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](https://api.dartlang.org/stable/2.0.0/dart-html/EventSource-class.html), feel free!## Install
Add to your `pubspec.yaml`:
```yaml
dependencies:
w3c_event_source: ^1.3.2
```## Usage
```dart
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](./LICENSE)
[EventSource]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource