hedera-web/js/vn/lot.js

66 lines
1.2 KiB
JavaScript

var VnObject = require('./object');
var LotIface = require('./lot-iface');
var Value = require('./value');
module.exports = new Class({
Extends: VnObject
,Implements: LotIface
,Tag: 'vn-lot'
,Properties: {
$: {
type: Object
,set: function(x) {
this.setAll(x);
}
,get: function() {
return this._params;
}
}
,params: {
type: Object
,set: function(x) {
this.$ = x;
}
,get: function() {
return this.$;
}
}
}
,initialize: function(props) {
this._params = {};
VnObject.prototype.initialize.call(this, props);
}
,keys: function() {
return Object.keys(this._params);
}
,assign: function(params) {
var diff = Value.partialDiff(this._params, params);
this._assign(diff);
}
,setAll: function(params) {
var diff = Value.diff(this._params, params);
this._assign(diff);
}
,_assign: function(diff) {
if (diff) {
Object.assign(this._params, diff);
this._paramsChanged(diff);
this.changed(diff);
}
}
/**
* Called when lot params changes, can be implemented by child classes to be
* notified about changes.
*
* @param {Object} diff Changed parameters and its new values
*/
,_paramsChanged: function() {}
});