Is it possible to differentiate between dependencies which are needed on structure build (like inheritance) and runtime dependencies (within a method call).
A little example:
2 "classes": Father and Child which depend on each other
Father.js
define(['Child'], function (Child) {
function Father() {};
Father.prototype.childs = [];
Father.prototype.addChild = function (c) {
if (!(c instanceof Child)) {
alert("nope");
}
}
return Father;
});
Child.js
define(['Father'], function(Father){
function Child(){
this.father = [];
}
Child.prototype.setFather = function(f){
if(!(f instanceof Father)){
alert("false");
}
}
return Child;
});
and an app.js
requirejs(['Child', 'Father'], function(Child, Father){
var c = new Child();
var f = new Father();
c.setFather(f);
f.addChild(c);
});
When using export you can only extend an object (if i'm correct). So is it possible to build a structure like this ?
What i actually try to do: have an automatic "class"-loading (seperated files), which loads all dependencies within a bigger model, which has some circular dependencies. Some dependencies needed right away (inheritance) and some are only needed after object initiation. And I cant find a nice solution for my problem.