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

ngraph.events

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngraph.events

Basic events supoort for ngraph.js

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
84K
decreased by-7.64%
Maintainers
1
Weekly downloads
 
Created
Source

ngraph.events

Small and powerful eventing in node and browser

build status Example

var eventify = require('ngraph.events');
var yourObject = {}; // any javascript object

eventify(yourObject);

// now any object can listen to events from your object
yourObject.on('beep', function(name) { console.log('Hello ' + name); });

// and you can fire events from your object:
yourObject.fire('beep', 'World!'); // prints 'Hello World!'

// stop listen to events:
yourObject.off('beep');

More advanced examples:

var eventify = require('ngraph.events');
var yourObject = eventify({});

// Pass context to event handler as last argument:
yourObject.on('beep', function () { console.log(this === yourObject); }, yourObject);
yourObject.fire('beep'); // prints true;

// Pass additional arguments to fire:
var onBop = function (x, y) { console.log(x + y); };
yourObject.on('bop', onBop);
yourObject.fire('bop', 40, 2); // prints 42;

// Remove given event handler for 'bop' event
yourObject.off('bop', onBop);

// Remove all event listeners from your object:
yourObject.off();

Why?

This module is a part of larger experiment which I'm currently working on. EventEmitter seemed to be pretty heavyweighted for my needs, so I rolled out this tiny library :).

Install

With npm do:

npm install ngraph.events

License

BSD 3-Clause

Keywords

FAQs

Package last updated on 01 Jun 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