A nice Server-Sent Events api
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
Install with component(1):
$ component install segmentio/sse
Subscribe fn
to events on url
. Returns an unbind
function.
MIT