Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/sse
A Server-Sent Events component
https://github.com/segment-boneyard/sse
Last synced: about 5 hours ago
JSON representation
A Server-Sent Events component
- Host: GitHub
- URL: https://github.com/segment-boneyard/sse
- Owner: segment-boneyard
- Created: 2014-01-11T11:17:58.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-18T08:10:23.000Z (over 10 years ago)
- Last Synced: 2024-04-09T16:31:15.154Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 153 KB
- Stars: 60
- Watchers: 41
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# sse
A nice [Server-Sent Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/) api
## Example
With a SSE endpoint that responds like this:
```bash
$ curl http://localhost/updates
data: foodata: bar
data: quit
```
And a script that subscribes to its updates:
```js
var sse = require('sse');var unbind = sse('/updates', function(data){
if (data == 'quit') unbind();
console.log(data);
});
```The console output will be:
foo
bar
quit## Installation
Install with [component(1)](http://component.io):
$ component install segmentio/sse
## API
### sse(url, fn)
Subscribe `fn` to events on `url`. Returns an `unbind` function.
## License
MIT