From 59203d64bb6cafbae3d15a853bd25342a6a31858 Mon Sep 17 00:00:00 2001 From: MK Date: Wed, 14 Oct 2015 14:28:28 -0400 Subject: [PATCH] README new way to use --- README.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 622d5c0..7411bf6 100644 --- a/README.md +++ b/README.md @@ -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 () { @@ -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.