# cocktail-annotation-evented

> CocktailJS Custom Annotation Evented

Latest version **0.0.3** (published 2013-12-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install cocktail-annotation-evented
pnpm add cocktail-annotation-evented
yarn add cocktail-annotation-evented
bun add cocktail-annotation-evented
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2013-12-04 |
| First published | 2013-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Maximiliano Fierro |
| Maintainers | elmasse |

## Links

- npm: https://www.npmjs.com/package/cocktail-annotation-evented
- Repository: https://github.com/CocktailJS/cocktail-annotation-evented
- npm.io page: https://npm.io/package/cocktail-annotation-evented

## Dependencies (2)

- [cocktail](https://npm.io/package/cocktail.md) ~0.5.0
- [cocktail-trait-eventable](https://npm.io/package/cocktail-trait-eventable.md) 0.0.5

## Recent versions

- 0.0.3 (latest) — 2013-12-04
- 0.0.2 — 2013-12-03
- 0.0.1 — 2013-11-29

## README

[![Build Status](https://travis-ci.org/CocktailJS/cocktail-annotation-evented.png?branch=master)](https://travis-ci.org/CocktailJS/cocktail-annotation-evented)
[![NPM version](https://badge.fury.io/js/cocktail-annotation-evented.png)](http://badge.fury.io/js/cocktail-annotation-evented)

# cocktail-annotation-evented
## A [CocktailJS](http://cocktailjs.github.io) Annotation Extension

This extension defines a custom annotation to apply [Eventable Trait](https://npmjs.org/package/cocktail-trait-eventable) and creates the required glue code into the host class.

### Install

````bash
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

````javascript
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
````javascript

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`.

---
_Source: https://npm.io/package/cocktail-annotation-evented · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
