Es6 Classes
by Terrance Smith
Babel + JSX
class Capsule {
constructor() {
this.uid = null; // userv.UserId;
this.guid = null; // testv.GUID;
this.json = null; // obsRowsV; collection of observableInfo
}
get uid() {
return this._uid;
}
set uid(val) {
this._uid = val;
}
get guid() {
return this._guid;
}
set guid(val) {
this._guid = val;
}
get json() {
return this._json;
}
set json(val) {
this._json = val;
}
isValid() {
return (!_.isNull(this._json) && !_.isUndefined(this._json) && !_.isUndefined(this._json.length) && this._json.length > 0);
}
}
let test = new Capsule();
test.uid = 'Ello';
test.guid = 'some guid';
test.json = 'some json';
if(test.isValid()){
console.log('test is valid');
console.log(test);
}else{
console.log('test is not valid');
}