1.6.0 • Published 6 years ago

event-source-stream v1.6.0

Weekly downloads
170
License
MIT
Repository
github
Last release
6 years ago

event-source-stream

EventSource implemented in node as a readable stream

npm install event-source-stream

build status dat

Usage

var ess = require('event-source-stream')

ess('http://server-sent-events-demo.herokuapp.com/update')
  .on('data', function(data) {
    console.log('received event:', data)
  })

Per default it will retry after 3s when the connection terminates. Change this by setting the retry option

// no retries
ess('http://server-sent-events-demo.herokuapp.com/update', {retry:false}).pipe(...)

// retry after 10s
ess('http://server-sent-events-demo.herokuapp.com/update', {retry:10000}).pipe(...)

Browser support

It also works in the browser using browserify

var ess = require('event-source-stream') // will use EventSource behind the scene

ess('http://server-sent-events-demo.herokuapp.com/update')
  .on('data', function(data) {
    console.log('recevied event in the browser', data)
  })

License

MIT

1.6.0

6 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.2

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago