HenrikJoreteg / wildemitter

A super lightweight EventEmitter similar to what comes in Node.js, but with a support for wildcard events '*'
MIT License
213 stars 21 forks source link

Add a `WildEmitter.mixin(<constructor>)` method for mixing emitter behaviour into a "class" more easily. #8

Closed latentflip closed 8 years ago

latentflip commented 10 years ago

So I love WildEmitter, but I can literally never remember how to actually use it. And even when I read the docs I forget that I have to both inherit from a new Emitter, and do Emitter.call(this) in my constructor, I always forget one or the other.

This PR makes it as easy as

var Emitter = require('wildemitter');

function Fruit () {
  //My own constructor code
}

Emitter.mixin(Fruit)

And doesn't break backwards compatibility.

floatdrop commented 10 years ago

You can use lodash mixin method for that.

austinkelleher commented 9 years ago

Is this something we are still interested in pursing? This was opened quite some time ago. @HenrikJoreteg

HenrikJoreteg commented 9 years ago

@austinkelleher i think it makes sense, if you want to get it done, i'm a +1.

kohenkatz commented 8 years ago

:+1: I like this. It looks so much cleaner than the old way.

Among other things, it will also mean we can stop using this.

HenrikJoreteg commented 8 years ago

I'm happy to merge this, but it's too out of sync with master. If someone wants to get it back up to speed, i'm happy to give them access to merge/publish.

kohenkatz commented 8 years ago

I'll make a new Pull Request

HenrikJoreteg commented 8 years ago

@kohenkatz i've added you as a contributor here as well. Happy to give you npm access too, just need your username there.

kohenkatz commented 8 years ago

Closing in favor of #15.

kohenkatz commented 8 years ago

@HenrikJoreteg Thanks. My npm username is the same as my Github - kohenkatz