Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 589 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 589 Bytes

sse-observable

fetch-based SSE client/EventSource with event emitter interface (WIP ⚠️)

Install

$ npm install --save sse-observable

Usage

const connectSSE = require('sse-observable');

const sse = connectSSE('/sse/endpoint/', {
  headers: { Authorization: 'Bearer ...' }
});

sse.on('open', () => console.log('SSE connection openned! 🎉'));
sse.on('message', data => {}));
sse.on('custom-event', data => {}));
sse.on('error', err => console.log('SSE connection failed: ', err));

License

MIT License