Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqemitter

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqemitter

An Opinionated Message Queue with an emitter-style API

  • 6.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is mqemitter?

The 'mqemitter' npm package is a simple message queue emitter that allows you to publish and subscribe to messages. It is designed to be lightweight and easy to use, making it suitable for applications that require basic message queuing and event handling.

What are mqemitter's main functionalities?

Publishing Messages

This feature allows you to publish messages to a specific topic. The code sample demonstrates how to create an instance of MQEmitter and publish a message with a topic and payload.

const MQEmitter = require('mqemitter');
const emitter = MQEmitter();

emitter.emit({ topic: 'myTopic', payload: 'Hello, World!' }, (err) => {
  if (err) {
    console.error('Error publishing message:', err);
  } else {
    console.log('Message published successfully');
  }
});

Subscribing to Messages

This feature allows you to subscribe to messages on a specific topic. The code sample shows how to set up a subscription to a topic and handle incoming messages.

const MQEmitter = require('mqemitter');
const emitter = MQEmitter();

emitter.on('myTopic', (message, cb) => {
  console.log('Received message:', message.payload);
  cb();
});

Unsubscribing from Messages

This feature allows you to unsubscribe from messages on a specific topic. The code sample demonstrates how to remove a previously set up subscription.

const MQEmitter = require('mqemitter');
const emitter = MQEmitter();

const handler = (message, cb) => {
  console.log('Received message:', message.payload);
  cb();
};

emitter.on('myTopic', handler);

// Later, to unsubscribe
emitter.removeListener('myTopic', handler);

Other packages similar to mqemitter

Keywords

FAQs

Package last updated on 24 Jul 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