Re: [NEW] Servoy Tutorials
Posted: Tue Nov 26, 2013 8:53 pm
Thanks for the feedback.
We were looking for a solution to get code-completion working for the object's prototype; if you add functions to the prototype Servoy will not see them in code complete.
So, I agree, this works fine. I don't need anything special; Servoy can code complete everything in the constructor shown below including Person.fullName() (no JSDoc warnings either). I don't need any @constructor tag.
However, if you take the function and put it on the prototype for the object, then Servoy cannot see it (no code complete and you get JSDoc warning), but it still works fine. You have to do it in the prototype like this:
As well, Servoy cannot see functions that are in a Revealing Module pattern, an object constructor that hides private variables / functions and only exposes certain things to the external world, like an api. In this case, although the functions are in the object constructor, Servoy does not see the "type" or "getInfo" functions.
I think the JSDoc @constructor tag is used more for documentation (let others know what it is or maybe auto-generate API docs). I don't think Servoy does anything with it.
We were looking for a solution to get code-completion working for the object's prototype; if you add functions to the prototype Servoy will not see them in code complete.
So, I agree, this works fine. I don't need anything special; Servoy can code complete everything in the constructor shown below including Person.fullName() (no JSDoc warnings either). I don't need any @constructor tag.
- Code: Select all
function Person (firstName, lastName, title){
this.firstName = firstName;
this.lastName = lastName;
this.title = title;
this.fullName = function(){
return this.firstName + " " + this.lastName;
}
}
However, if you take the function and put it on the prototype for the object, then Servoy cannot see it (no code complete and you get JSDoc warning), but it still works fine. You have to do it in the prototype like this:
- Code: Select all
var Person_proto = function(){
Person.prototype = {
fullName : function(){
return this.firstName + " " + this.lastName;
},
fullNameTitle : function(){
return this.fullName() + ", " + this.title;
}
}
}();
As well, Servoy cannot see functions that are in a Revealing Module pattern, an object constructor that hides private variables / functions and only exposes certain things to the external world, like an api. In this case, although the functions are in the object constructor, Servoy does not see the "type" or "getInfo" functions.
- Code: Select all
function Fruit2(name, color, rating, price) {
var _name = name,
_color = color,
_rating = rating,
_price = price,
type = function () {
return 'I am a ' + _color + ' ' + _name;
},
getInfo = function(){
return 'Rating: ' + _rating + ', Price: ' + _price
};
// Servoy does not see the public functions exposed here
return {
type: type,
getInfo: getInfo
};
}
I think the JSDoc @constructor tag is used more for documentation (let others know what it is or maybe auto-generate API docs). I don't think Servoy does anything with it.