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

70 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-05-30 01:30:33 +00:00
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: {
2022-06-06 12:49:18 +00:00
$: {
2022-05-30 01:30:33 +00:00
type: Object
2022-11-16 01:46:44 +00:00
,set(x) {
2022-05-30 01:30:33 +00:00
this.setAll(x);
}
2022-11-16 01:46:44 +00:00
,get() {
2022-05-30 01:30:33 +00:00
return this._params;
}
}
2022-06-06 12:49:18 +00:00
,params: {
2022-05-30 01:30:33 +00:00
type: Object
2022-11-16 01:46:44 +00:00
,set(x) {
2022-06-06 12:49:18 +00:00
this.$ = x;
2022-05-30 01:30:33 +00:00
}
2022-11-16 01:46:44 +00:00
,get() {
2022-06-06 12:49:18 +00:00
return this.$;
2022-05-30 01:30:33 +00:00
}
}
}
2022-11-16 01:46:44 +00:00
,initialize(props) {
2022-06-18 21:04:34 +00:00
this._params = new Proxy({}, {
set(obj, prop, value) {
return Reflect.set(obj, prop, value);
}
});
2022-06-06 16:02:17 +00:00
VnObject.prototype.initialize.call(this, props);
2022-05-30 01:30:33 +00:00
}
2022-11-16 01:46:44 +00:00
,keys() {
2022-05-30 01:30:33 +00:00
return Object.keys(this._params);
}
2022-11-16 01:46:44 +00:00
,assign(params) {
2022-05-30 01:30:33 +00:00
var diff = Value.partialDiff(this._params, params);
this._assign(diff);
}
2022-11-16 01:46:44 +00:00
,setAll(params) {
2022-05-30 01:30:33 +00:00
var diff = Value.diff(this._params, params);
this._assign(diff);
}
2022-11-16 01:46:44 +00:00
,_assign(diff) {
2022-05-30 01:30:33 +00:00
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
*/
2022-11-16 01:46:44 +00:00
,_paramsChanged() {}
2022-05-30 01:30:33 +00:00
});