0
1
Fork 0
hedera-web-mindshore/js/vn/lot-iface.js

83 lines
1.5 KiB
JavaScript

/**
* Holds a plain key-value javascript object and monitorizes changes over it.
*/
module.exports = new Class({
Properties: {
/**
* The internal object with the params, this is the lot internal object
* and should be used for read-only purposes.
*/
params: {
type: Object
}
/**
* Shortcut for params property.
*/
,$: {
type: Object
}
}
/**
* Gets a value from the lot.
*
* @param {string} field The field name
* @return {*} The field value
*/
,get: function(field) {
return this.params[field];
}
/**
* Sets a value on the lot.
*
* @param {string} field The field name
* @param {*} value The new field value
*/
,set: function(field, value) {
var params = {};
params[field] = value;
this.assign(params);
}
/**
* Returns an array with the lot keys.
*
* @return {Array} The lot keys
*/
,keys: function() {}
/**
* Emits the 'change' signal on the lot.
*
* @param {Object} changes The changed params and its values
*/
,changed: function(changes) {
this.emit('change', changes);
}
/**
* Copies all values from another lot.
*
* @param {Object} object The source object
*/
,assign: function() {}
/**
* Copies all values from another lot.
*
* @param {LotIface} lot The source lot
*/
,assignLot: function(lot) {
this.assign(lot.$);
}
/**
* Resets all values.
*/
,reset: function() {
this.params = {};
}
});