Object Model
Create a class
var myClass = vs.core.createClass ({
// parent class
parent: vs.ui.View,
// properties declaration
properties : {text: vs.core.Object.PROPERTY_IN_OUT},
// prototype declaration
aMethod : function (p1, p2, …) {
this._super (p1, p2, …);
…
},
…
});
Instantiate an object from a class
var config = {
id: 'xxx',
text: ''
}
// Object construction
var obj = new myClass (config);
// Object initialization
obj.init ();
// property manipulation
obj.text = 'Hello';
Properties
Basic declaration
properties : {propName: vs.core.Object.PROPERTY_IN_OUT},
Possible export values are:
- vs.core.Object.PROPERTY_IN_OUT
- vs.core.Object.PROPERTY_IN
- vs.core.Object.PROPERTY_OUT
Descriptor declaration
properties : {
propName: {
set : function (v) {
…
this._prop_name = v;
},
get : function () {
…
return this._prop_name
}
}
},
Path declaration
This third syntax allows to easily export a child component's property.
Within this example, my class exports as own property, the property named 'text' of its child 'textField'.
properties : {text: "textField#text"}
This declaration is similar to:
properties : {
text: {
set : function (v) {
this.textField.text = v;
},
get : function () {
return this.textField.text;
}
}
},
Object life cycle
Construction
- constructor
- init
- initComponent
- configure
- componentDidInitialize
-
(create the view in case of UI object)
initComponent
componentDidInitialize
Can be surcharge to know when the component is ready to use. It is useful when you want to add event bindings on it self or on child.Add a view
- add
- viewDidAdd
© 2013 David Thevenin, ViniSketch, IGEL.