Socket
Socket
Sign inDemoInstall

launchdarkly-eventsource

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

launchdarkly-eventsource

Fork of eventsource package - W3C compliant EventSource client for Node.js and browser (polyfill)


Version published
Weekly downloads
1M
decreased by-8.34%
Maintainers
1
Weekly downloads
 
Created

What is launchdarkly-eventsource?

The launchdarkly-eventsource npm package is a client for consuming server-sent events (SSE) from LaunchDarkly. It allows you to listen to real-time updates from LaunchDarkly's feature flag service, making it useful for applications that need to react to changes in feature flags without polling.

What are launchdarkly-eventsource's main functionalities?

Connecting to an Event Stream

This feature allows you to connect to an event stream using a specified URL. The code sample demonstrates how to open a connection and handle open and error events.

const { EventSource } = require('launchdarkly-eventsource');

const url = 'https://example.com/events';
const es = new EventSource(url);

es.onopen = () => {
  console.log('Connection to event stream opened.');
};

es.onerror = (err) => {
  console.error('Error in event stream:', err);
};

Listening to Specific Events

This feature allows you to listen to specific events from the event stream. The code sample shows how to listen for 'message' and 'custom-event' events and handle them accordingly.

es.addEventListener('message', (event) => {
  console.log('New message event:', event.data);
});

es.addEventListener('custom-event', (event) => {
  console.log('Custom event received:', event.data);
});

Closing the Event Stream

This feature allows you to close the event stream connection. The code sample demonstrates how to close the connection and log a message.

es.close();
console.log('Event stream closed.');

Other packages similar to launchdarkly-eventsource

Keywords

FAQs

Package last updated on 22 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc