Sha256: 448b55e36974fb91e9257352d3bc0607ff414713b8fba5e87792cdba0ff94880

Contents?: true

Size: 1.34 KB

Versions: 267

Compression:

Stored size: 1.34 KB

Contents

# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)

  Event emitter component.

## Installation

```
$ component install component/emitter
```

## API

### Emitter(obj)

  The `Emitter` may also be used as a mixin. For example
  a "plain" object may become an emitter, or you may
  extend an existing prototype.

  As an `Emitter` instance:

```js
var Emitter = require('emitter');
var emitter = new Emitter;
emitter.emit('something');
```

  As a mixin:

```js
var Emitter = require('emitter');
var user = { name: 'tobi' };
Emitter(user);

user.emit('im a user');
```

  As a prototype mixin:

```js
var Emitter = require('emitter');
Emitter(User.prototype);
```

### Emitter#on(event, fn)

  Register an `event` handler `fn`.

### Emitter#once(event, fn)

  Register a single-shot `event` handler `fn`,
  removed immediately after it is invoked the
  first time.

### Emitter#off(event, fn)

  * Pass `event` and `fn` to remove a listener.
  * Pass `event` to remove all listeners on that event.
  * Pass nothing to remove all listeners on all events.

### Emitter#emit(event, ...)

  Emit an `event` with variable option args.

### Emitter#listeners(event)

  Return an array of callbacks, or an empty array.

### Emitter#hasListeners(event)

  Check if this emitter has `event` handlers.

## License

MIT

Version data entries

267 entries across 90 versions & 4 rubygems

Version Path
blackboard-3.1.9 lib/site_template/node_modules/component-emitter/Readme.md
blackboard-3.1.9 lib/site_template/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
flok-0.0.105 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.103 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
flok-0.0.102 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io-client/node_modules/component-emitter/Readme.md
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/socket.io/node_modules/socket.io-adapter/node_modules/socket.io-parser/node_modules/component-emitter/Readme.md