w3c_event_source 1.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new70

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.0.0

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

event_source change log

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning.

1.1.0

  • Implement auto-reconnect.

1.0.0

  • Initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  w3c_event_source: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:w3c_event_source/w3c_event_source.dart';
  
Version Uploaded Documentation Archive
1.1.0 Oct 14, 2018 Go to the documentation of w3c_event_source 1.1.0 Download w3c_event_source 1.1.0 archive
1.0.0 Oct 13, 2018 Go to the documentation of w3c_event_source 1.0.0 Download w3c_event_source 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Oct 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:w3c_event_source/w3c_event_source.dart with components: io.

Health suggestions

Format lib/event_source.dart.

Run dartfmt to format lib/event_source.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use w3c_event_source.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test any