Object - globules-io/OGX.JS GitHub Wiki
OGX.Object
is a static class that handles the creation of classes extending multiple classes. It goes along its reserved keywords, require and construct.
Extending
Here are the steps to create a super object with
OGX.Object
. When creating a custom class, you must declare its extensions this way
require('The class you are creating', 'extendA', 'extendB', ... 'extendZ');
Then, When declaring your class, the FIRST line must be
construct(this, 'The class you are creating');
Which calls
OGX.Object
in the shadows and puts everything together for you. Then when finally an instance must be created by doing
OGX.Object.create(class, config);
Altogether, if an object extends multiple classes
require('MyNameSpace.MyCustomObject', 'Uxi', 'Touch', 'Resize');
OGX.MyNameSpace.MyCustomObject = function(__config){
//__config is the config used to instantiate
construct(this, 'MyNameSpace.MyCustomObject');
//construct receives data coming from a route (__data)
//and data coming from a data:Data node (__extra_data)
this.construct = function(__data, __extra_data){
}
};
let config = {}; //whatever you need for your object
let o = OGX.Object.create('MyNameSpace.MyCustomObject', config);
//call final construct of your instance when you want
o.construct(o);
Creating your custom object from any
Uxi
node, construct will be fired automatically
let config = {}; //whatever you need for your object
let o = this.create('MyNameSpace.MyCustomObject', config);
Note that it is recommended to at least extend the
Uxi
class. If your object will handle user interactions, you should also extend theTouch
class.
Methods
Retrieve some
Uxi
's passing a query. See querying in List.
OGX.Object.get(_QUERY_, _SORT_, _LIMIT_);
Instancing
To create a new instance of any OGX objects, please see the section dedicated to this in OML