How to use reconnecting-eventsource - 1 common examples

To help you get started, we’ve selected a few reconnecting-eventsource examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fanout / reconnecting-eventsource / etc / nodejs-example / index.js View on Github external
EventSource = require('eventsource');
const ReconnectingEventSource = require('reconnecting-eventsource').default;
const sseUrl = "https://example.com/events"; // will 404
const eventSource = new ReconnectingEventSource(sseUrl, {});
eventSource.addEventListener('error', (error) => {
  console.error('eventSource error', error);
});
eventSource.addEventListener('message', function(ev) {
  console.log('id: ', ev.lastEventId);
  console.log('message: ', ev.data);
});

reconnecting-eventsource

wrapper library around the JavaScript EventSource API to ensure it maintains a connection to the server.

MIT
Latest version published 2 months ago

Package Health Score

76 / 100
Full package analysis

Popular reconnecting-eventsource functions