--- a/svghmi/widgets_common.ysl2 Thu Aug 13 11:30:18 2020 +0200
+++ b/svghmi/widgets_common.ysl2 Thu Aug 13 11:37:39 2020 +0200
@@ -158,18 +158,12 @@
}
apply_cache() {
- let dispatch = this.dispatch;
- if(dispatch == undefined) return;
if(!this.unsubscribable) for(let index in this.indexes){
/* dispatch current cache in newly opened page widgets */
let realindex = this.get_variable_index(index);
let cached_val = cache[realindex];
if(cached_val != undefined)
- try {
- dispatch.call(this, cached_val, cached_val, index);
- } catch(err) {
- console.log(err);
- }
+ this._dispatch(cached_val, cached_val, index);
}
}
@@ -194,22 +188,27 @@
new_hmi_value(index, value, oldval) {
// TODO avoid searching, store index at sub()
- let dispatch = this.dispatch;
- if(dispatch == undefined) return;
for(let i = 0; i < this.indexes.length; i++) {
let refindex = this.get_variable_index(i);
if(index == refindex) {
- try {
- dispatch.call(this, value, oldval, i);
- } catch(err) {
- console.log(err);
- }
+ this._dispatch(value, oldval, i);
break;
}
}
}
+ _dispatch(value, oldval, varnum) {
+ let dispatch = this.dispatch;
+ if(dispatch != undefined){
+ try {
+ dispatch.call(this, value, oldval, varnum);
+ } catch(err) {
+ console.log(err);
+ }
+ }
+ }
+
_animate(){
this.animate();
this.pending_animate = false;