On Sep 22, 1:16 am, "Les Szklanny" <[EMAIL PROTECTED]> wrote:
> Do we support multiple mixins as
> in Dojo? How do I invoke constructors of these mixins?
There is no sense to invoke constructor of mixins (in Dojo is not
invoked too):
How to support mixins in Prototype? Goo question.
We can define this function:
Object.provide = function(dst, src) {
for (var key in src)
if ( !(key in dst) )
dst[key] = src[key];
return dst;
};
so we will be able to do this:
Object.provide(MyClass.prototype, Enumerable);
But Enumerable is not a Class. So consider this function too:
Function.prototype.mixin = function() {
for (var i = 0, arg; i < arguments.length; ++i) {
arg = arguments[i];
if (typeof arg == 'function') {
Object.provide(this, arg); //static methods too?
Object.provide(this.prototype, arg.prototype);
} else {
Object.provide(this.prototype, arg);
}
}
return this;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---