Skip to content

segment-boneyard/sse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sse

A nice Server-Sent Events api

Example

With a SSE endpoint that responds like this:

$ curl http://localhost/updates
data: foo

data: bar

data: quit

And a script that subscribes to its updates:

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):

$ component install segmentio/sse

API

sse(url, fn)

Subscribe fn to events on url. Returns an unbind function.

License

MIT

About

A Server-Sent Events component

Resources

Stars

Watchers

Forks

Packages

No packages published