Option name | Type | Description |
---|---|---|
config.className | string |
|
['Component'] | string | config.superClassName - The name of an existing component to be used as the new component's super class |
config.facets | object |
|
config.methods | object |
|
config.staticMethods | object |
|
Utility function which creates and registers new milo component. The component created will have
a reference to the super class used in its creation (Accessible using
function createComponentClass(config) {
check(config, {
superClassName: Match.Optional(String),
className: String,
facets: Match.Optional(Object),
methods: Match.Optional(Match.ObjectHash(Function)),
staticMethods: Match.Optional(Match.ObjectHash(Function)),
});
var SuperClass = componentRegistry.get(config.superClassName || 'Component');
var ComponentClass = SuperClass.createComponentClass(config.className, config.facets);
if (config.methods) _.extendProto(ComponentClass, config.methods);
if (config.staticMethods) {
if (config.staticMethods.super !== undefined) throw '\'super\' is a reserved keyword';
_.extend(ComponentClass, config.staticMethods);
}
ComponentClass.super = SuperClass.prototype;
componentRegistry.add(ComponentClass);
return ComponentClass;
}