Skip to content

juliangruber/co-sse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-sse

Server-Sent Events generator stream.

build status

Example

Create a sse stream from a function:

var sse = require('co-sse');
var wait = require('co-wait');
var co = require('co');

co(function*(){
  var read = sse(function*(){
    yield wait(1000);
    return Date.now() + '';
  });

  var data;
  while (data = yield read) console.log(data);
})();

Outputs:

$ make example
data: 1391517447428


data: 1391517448462


data: 1391517449464


data: 1391517450466


data: 1391517451467

Installation

$ npm install co-sse

API

sse(fn[, opts])

Create a generator function that reads and converts data from fn into the Server-Sent Events format.

Options:

  • retry: Set the retry interval

License

MIT

About

Server-Sent Events generator stream

Resources

Stars

Watchers

Forks

Packages

No packages published