Skip to content

Commit

Permalink
README new way to use
Browse files Browse the repository at this point in the history
  • Loading branch information
kohenkatz committed Oct 14, 2015
1 parent 4ad129b commit 59203d6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions README.md
Expand Up @@ -22,13 +22,10 @@ var Emitter = require('./wildemitter');
// the example object we're making
function Fruit(name) {
this.name = name;

// call emitter with this context
Emitter.call(this);
}

// inherit from Emitter
Fruit.prototype = new Emitter;
//Mix the emitter behaviour into Fruit
Emitter.mixin(Fruit);

// a function that emits an events when called
Fruit.prototype.test = function () {
Expand Down Expand Up @@ -84,6 +81,22 @@ orange.on('*', 'today', someHandler);
orange.releaseGroup('today');
```

### The old way

If you don't want to use `Emitter.mixin`, you can still use it the old way:

```js
function Fruit(name) {
this.name = name;

// call emitter with this context
Emitter.call(this);
}

// and also inherit from Emitter
Fruit.prototype = new Emitter;
```

## Including

Emitters are often something you want to be able to include in another lib. There's also file called wildemitter-bare.js that doesn't have any export mechanism.
Expand Down

0 comments on commit 59203d6

Please sign in to comment.