You're correct. Instead of implement(new emitter()),
implement(prime.create(emitter.prototype)) would be better (that won't call
the constructor, like new does, which is not necessary).

Prime is designed to be fast and small, and extra goodies MooTools Class
has, are left out. However if a 'mutator' method is in the object passed
into prime(), for example prime({mutator: function(key, method){...}}), you
can define your own way how methods or other stuff on the passed object is
implemented.

That way I could write Classy <https://github.com/arian/classy>, which is
prime but with (most) MooTools Class stuff, so also Implements, so you can
implement, or mixin other primes.


On Sat, May 26, 2012 at 10:24 PM, AHM <anders.hellerup.mad...@gmail.com>wrote:

> I am playing around with Mootools Prime and I can't figure out what the
> best way is to add events to a class. Or a prime, if that is a more correct
> way to refer to classes the new version?
>
> It looks like I can add events either by directly inheriting from the
> emitter class, which is awkward because then I can't inherit from other
> classes, or by calling implement(new emitter()) on the class after it is
> declared, which is also awkward because then the declaration have to go
> after the class definition. Presumably some of the methods on the class
> would like to call this.emit(), and it just feels a little wrong to have
> add the emit functionality after defining a method that uses it.
>
> Is there anything like the Implements property that the current Class
> supports?
>

Reply via email to