Socket
Socket
Sign inDemoInstall

cocktail-annotation-evented

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cocktail-annotation-evented

CocktailJS Custom Annotation Evented


Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Install size
44.3 kB
Created
Weekly downloads
 

Readme

Source

Build Status NPM version

cocktail-annotation-evented

A CocktailJS Annotation Extension

This extension defines a custom annotation to apply Eventable Trait and creates the required glue code into the host class.

Install

npm install cocktail --save
npm install cocktail-annotation-evented --save

Requirements

CocktailJS v0.5.0 or greater is required to use this annotation.

Usage

Using @evented annotation is quite easy. First we need to register the custom annotation with current cocktail instance.

MyClass.js

var cocktail = require('cocktail'),
    Evented  = require('cocktail-annotation-evented');

//register Evented annotation with current cocktail instance
cocktail.use(Evented);

cocktail.mix({
    '@exports': module
    '@as'     : 'class',

    // we can say that our class is evented by passing `true` as a param
    '@evented': true,

    doSomething: function(){
        this.emit('doingSomething', this);
    } 
});

index.js


var MyClass = require('./MyClass'),
    obj;

obj = new MyClass();

obj.on('doingSomething', function(){console.log('obj is doing something!');});

obj.doSomething();

API

  • @evented: parameter
    • parameter: {boolean} if the parameter is true, the evented annotation will create and add a new instance of node's events.EventEmitter.

FAQs

Last updated on 04 Dec 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc