featurehub_sse_client

Last updated:

0 purchases

featurehub_sse_client Image
featurehub_sse_client Images
Add to Cart

Description:

featurehub sse client

SSE-Client #
A client only library for using EventSource or Server-Sent Events (SSE).
This library implements the interface as described here.
Origin #
This packages is a clone of the eventsource library but because we have not been able to get critical changes
merged in, we have had to release this package instead. It drops the incomplete server functionality and we have
renamed the library to featurehub_sse_client.
Further, with Dart now supporting target platform detection (when detecting dart.io vs dart.html) it makes more sense
to use the browser specific SSE client (dart:html / EventSource) as it is native to the browser.
Client usage #
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: http.BrowserClient());
copied to clipboard
If you wish to have it connect only when the first listener attaches (and not otherwise), then pass the
optional parameter openOnlyOnFirstListener (as true). If you wish to close it after the last listener detaches, then
pass the optional parmeter closeOnLastListener.
EventSource eventSource = await EventSource.connect("http://example.com/events",
openOnlyOnFirstListener: true, closeOnLastListener: true);
copied to clipboard
You can also listen for events from the event source now, but you will need to provide your own stream controller. If
you wish to listen to the events as the stream opens and closes, please pass in a StreamController<>
Licensing #
This project is available under the MIT license, as can be found in the LICENSE file.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.