A library for using EventSource or Server-Sent Events (SSE). Both client and server functionality is provided.
This library implements the interface as described here.
For more advanced usage, see the example/
directory.
Creating a new EventSource client is as easy as a single call.
The http package is used under the hood, so wherever this package works, this lbirary will also work.
Browser usage is slightly different.
EventSource eventSource = await EventSource.connect("http://example.com/events");
// in browsers, you need to pass a http.BrowserClient:
EventSource eventSource = await EventSource.connect("http://example.com/events",
client: new http.BrowserClient());
We recommend using shelf_eventsource
for
serving Server-Sent Events.
This library provides an EventSourcePublisher
that manages subscriptions, channels, encoding.
We refer to documentation in the shelf_eventsource
package for more information.
This library also includes a server provider for dart:io
's HttpServer
in io_server.dart
.
However, it has some issues with data flushing that are yet to be resolved, so we recommend using
shelf instead.
This project is available under the MIT license, as can be found in the LICENSE file.
Add this to your package's pubspec.yaml file:
dependencies:
eventsource: "^0.1.0+2"
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 packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:eventsource/eventsource.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.1.0+2 | Apr 25, 2017 |
|
|
0.1.0+1 | Nov 28, 2016 |
|
|
0.1.0 | Nov 27, 2016 |
|
|
We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
49 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
92 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
99 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
72 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:eventsource/eventsource.dart
.
Fix analysis and formatting issues.
Analysis or formatting checks reported 2 errors 3 hints.
Strong-mode analysis of
lib/publisher.dart
failed with the following error:line: 109 col: 23
The argument type 'ProxySink' can't be assigned to the parameter type 'Sink<Event>'.Strong-mode analysis of
lib/src/decoder.dart
failed with the following error:line: 10 col: 7
Missing concrete implementations of 'StreamTransformer.cast' and 'StreamTransformer.retype'.Similar analysis of the following files failed:
lib/eventsource.dart
(hint)lib/src/encoder.dart
(hint)
Fix .analysis_options
.
We were unable to parse
.analysis_options
.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*
, it usually means that the author is still experimenting with the general direction API.
Maintain an example.
None of the files in your
example/
directory matches a known example patterns. Common file name patterns include:main.dart
,example.dart
or you could also useeventsource.dart
.
Use analysis_options.yaml
.
Rename old
.analysis_options
file toanalysis_options.yaml
.
Enable strong mode analysis.
Strong mode helps you to detect bugs and potential issues earlier.Start your
analysis_options.yaml
file with the following:analyzer: strong-mode: true
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.0.0 <2.0.0 | ||
collection | >=1.4.1 <2.0.0 | 1.14.9 | |
http | >=0.11.0 <0.12.0 | 0.11.3+16 | |
http_parser | >=2.2.0 <4.0.0 | 3.1.1 | |
logging | >=0.11.0 <0.12.0 | 0.11.3+1 | |
sync | >=0.1.0 <0.2.0 | 0.1.0+1 | |
Transitive dependencies | |||
async | 2.0.6 | ||
charcode | 1.1.1 | ||
path | 1.5.1 | ||
source_span | 1.4.0 | ||
string_scanner | 1.0.2 | ||
typed_data | 1.1.5 | ||
Dev dependencies | |||
test | >=0.12.0 <0.13.0 |