require("babel/polyfill");
import {Module} from '../Module.js';require("babel/polyfill");
import {Module} from '../Module.js';depends: Kronicle.Module The Component class is used to create components which are added to Views or other components. A component is a small, reusable module implementation. The constructor takes an args object that contains the properties:
export class Component extends Module {
    constructor (args = {components: [], template: () => { return "" }, name: ""}) {
        this.template = args.template;
        this.modules = {
            components: {}
        };
        if(args.components) {
            this.addComponents(args.components);
        }
        super({name: args.name + 'Component'});
        
    }The render method passes any data avaialbe to a template and returns the rendered string Takes two arguments
    render (err, data) {
        if(!err) {
            return this.template(data);
        }
    }This medthod add sub-components to the component, use this method to build a component with other components. Takes one argument:
    addComponents(components) {
        var aryComponents = components;
        if(!(components instanceof Array)){
            aryComponents = [components];
        }
        this.components = components;
        for(let component of aryComponents){
            if(component.name) {
                this.addComponentModule(component);
            } else {
                throw new Error('Error: components must have a unique name');
            }
        }
    }This method adds an individual sub-component to the component. Takes one argument:
    addComponentModule(component) {
        this.modules.components[component.name] = component
    }
}