Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Oct 9, 2012
1 parent c3fc7f5 commit 183adc1
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,30 @@ $ component install component/emitter

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:
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 obj = {};
Emitter(obj);
var Emitter = require('emitter');
Emitter(User.prototype);
```

Expand Down

0 comments on commit 183adc1

Please sign in to comment.