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

uevents.js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uevents.js

Micro events library for javascript. It works in the browser and has support for CommonJS and AMD loading built in. It can also be used on the server through `node.js`, but for most applications usage of the native `events` API should suffice.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

uevents.js

Micro events library for javascript. It works in the browser and has support for CommonJS and AMD loading built in. It can also be used on the server through node.js, but for most applications usage of the native events API should suffice.

This library has no external dependencies and weights less than 1kb when minified and gziped.

Complete API documentation is available here.

Basic Usage

You can create a new uevents object on which you can register callbacks for named events, and unregister callbacks for named events, and trigger events.

    // create new uevents object
    var obj = new uevents();

    // register callback for signal receiving two parmeters
    obj.on('signal', function (a, b) {
        console.log("a: " + a + ", b: " + b);
    });

    // trigger signal with 'A' and 'B'
    // should print "a: A, b: B"
    obj.trigger('signal', 'A', 'B');

    // trigger signal with 5 and 6
    // should print "a: 5, b: 6"
    obj.trigger('signal', 5, 6);

    // remove all callbacks for 'signal'
    obj.off('signal');

    // trigger signal 'A' and 'B'
    // nothing happens, no callbacks registered
    obj.trigger('signal', 'A', 'B');

You can also extend an existing object to allow it to emit and receive events using the same API.


    var obj = new ComplicatedCustomObject();

    uevents.extend(obj);

    // register callback for 'signal'
    obj.on('signal', function () {
        console.log('signal emitted');
    });

    // trigger callbacks for 'signal'
    obj.trigger('signal');

FAQs

Package last updated on 31 Dec 2013

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