actum / gulp-dev-stack

Actum dev stack based on gulp
MIT License
11 stars 7 forks source link

JS boilerplate: refactor classes to functions #33

Closed vbulant closed 8 years ago

vbulant commented 8 years ago
janpanschab commented 8 years ago
app.init = function(Klass, container, ...args) {
    if (container) {
        return new Klass(container, ...args);
    }
};

app.factory = function(Klass, containers, ...args) {
    return [...containers].map((container) => {
        return new Klass(container, ...args);
    });
};

app.initStatic = function(klass, container, ...args) {
    if (container) {
        return klass.init(container, ...args);
    }
};