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

eventm

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventm

Manage all events in your app

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Event Manager

Manage all events in your app

Install

npm install --save eventm

Usage

// -------------- BEHIND
const eventm = require('eventm')();

setTimeout(() => eventm.resolve('ready', 'BEHIND is ready'), 2000);

const behind = {
 ready: (cb) => eventm.on('ready', cb, { onlyData: true }),
};


// -------------- AHEAD
behind.ready((data) => console.log(data));

More examples

Functions

NameDescription
on(string: name, function: callback = null, object: options = {})on listen the name evenement and take callback or Promise for the response. callback have as default parameters (err, data)
resolve(any: data = undefined)resolve function is used to set a success response
reject(any: data = undefined)reject function is used to set an error response

On options

NameDefaultDescription
isUniquetruetrue = After the response the event is removed
onlyDatafalsetrue = Only data is return during the callback, err is ignored
promisefalsetrue = Enable Promise and on function return a Promise
cachefalsetrue = Keep data in cache for a futur call with a callback
removeCachefalsetrue = After the response all options and data are reset

Multi-channel

// -------------- BEHIND
const event = require('eventm')();
const eventChild = require('eventm')('child');
const eventParent = require('eventm')('parent');

setTimeout(() => event.resolve('ready', 'process is ready'), 1000);
setTimeout(() => eventChild.resolve('ready', 'child is ready'), 1500);
setTimeout(() => eventParent.resolve('ready', 'parent is ready'), 2000);

const behind = {
 ready: (cb) => event.on('ready', cb, { onlyData: true }),
 ready2: (cb) => eventChild.on('ready', cb, { onlyData: true }),
 ready3: (cb) => eventParent.on('ready', cb, { onlyData: true }),
};


// -------------- AHEAD
behind.ready((data) => console.log(data));
behind.ready2((data) => console.log(data));
behind.ready3((data) => console.log(data));

Keywords

FAQs

Package last updated on 17 Jul 2018

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