Closed jfrux closed 11 years ago
_.extend() simply loops over the publicly accessible members of an object/struct and copies them to the new object/struct.
Coldfusion's component extends="..." syntax allows you to define actual inheritance, which is what it sounds like you're looking for?
bump
not necessarily looking for extends, looking to take the function definitions of one cfc and use them as mixin functions on another cfc.
extends only allows one cfc, but if we want to make two diff cfc's mixin to the existing cfc.
similar to how you can include("mixin_functions.cfm") within a component and pull in a cfm of functions but without the need for the cfm file :)
maybe a new module for handling mixins...? :D
component name="core" {
...
public any function includes(mixins...) {
for (mixin in mixins) {
var mixinFuncs = getComponentMetaData(mixin);
for (func in mixinFuncs) {
this[func.name] = func;
}
}
}
...
}
component name="someBasicClass" extends="foundry.core" {
includes("./someMixinFuncs");
}
Hmm, can you provide an example of how you're trying to use _.extend() ?
i just reviewed this again, and i'm not sure that this sort of functionality makes sense for this project, given that it is intended to be a port of Underscore.js and there isn't anything in Underscore.js that does mixins for classes (yet)
I'm trying to mixin a cfc's functions and "property" definitions, what is the best way to do this without initing?
For instance,
this = _.extend(this,new Paths());
I'd love to just be able to mixin the methods / property definitions of "Paths" instead of initing it and returning itself... There's gotta be a better way!