New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

js-simple-events

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-simple-events

Yet another simple event management system

  • 1.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
70
decreased by-4.11%
Maintainers
2
Weekly downloads
 
Created
Source

js-simple-events

Yet another simple event management system

npm i -S js-simple-events

About

This is just a simple class that helps to manage events in a simple way without dependencies. It also supports TypeScript!

And it's really light - <1kb in size!

Methods

MethodParamsDescription
emitevent, payloadEmit the event with the given payload.
fireevent, payloadAlias for emit
onevent, callbackListen for the event with the given callback.
listenevent, callbackAlias for on
onceevent, callbackListen for the event once, after handling - remove the listener.
offevent, callbackRemove event listener(s) for the event.
removeevent, callbackAlias for off

Examples

// Import and initialize
import EventManager from 'js-simple-events'

const eventManager = new EventManager();


// Define handlers
const eventHandler = (payload) => console.log('Yay, events work!', payload);

eventManager.on('test', eventHandler);
eventManager.once('test', () => console.log('This will be called just once!'));

// Emit events
eventManager.emit('test', 'Hello!');
// -> Yay, events work! Hello!
// -> This will be called just once!

eventManager.emit('test', 'Hello!');
// -> Yay, events work! Hello!
// (The 'once' handler isn't fired)

Plugins

For Vue.js

Keywords

FAQs

Package last updated on 16 Oct 2019

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