You can set up "private" items (context variables available to some public interface) in the construct's init() method.
> can.Construct.extend("Bar", {
init : function() {
var b = 0;
this.binc = function(){ return ++b; };
}
});
function Constructor() {
// All construction is actually done in the init method.
if (!initializing) {
return this.constructor !== Constructor &&
// We are being called without `new` or we are extending.
arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) :
// We are being called with `new`.
Constructor.newInstance.apply(Constructor, arguments);
}
} dashboard.js:13297 > b = new Bar();
> b.binc()
1
> b.binc()
2
> b.binc()
3
> c = new Bar()
> c.binc()
1
> c.binc()
2
> b.binc()
4