I'd like to use qx-oo (Qooxdoo) as OOP library. But I was confused by strange behaviour of field members. It's looks like that fields are shared between all objects of one class, like static members. For example, this test code
qx.Class.define("com.BaseClass",
{
extend : qx.core.Object,
members:
{
_children: [],
getChildrenCount: function(){
return this._children.length;
},
addChild: function(child){
this._children.push(child);
}
}
});
var class1 = new com.BaseClass();
var class2 = new com.BaseClass();
showLog("class1.getChildrenCount() - " + class1.getChildrenCount())
showLog("class2.getChildrenCount() - " + class2.getChildrenCount())
class1.addChild("somechild");
showLog("class1.getChildrenCount() - " + class1.getChildrenCount())
showLog("class2.getChildrenCount() - " + class2.getChildrenCount())
will produce such log
class1.getChildrenCount() - 0
class2.getChildrenCount() - 0
class1.getChildrenCount() - 1
class2.getChildrenCount() - 1
Is there a way to accomplish this?
Or can you advice another OOP-js-lib?
Here's a full example.