svghmi/widgets_common.ysl2
branchsvghmi
changeset 2980 2a21d6060d64
parent 2963 113e2f2e324d
child 2997 2f298089e32e
--- a/svghmi/widgets_common.ysl2	Wed Jun 03 13:31:55 2020 +0200
+++ b/svghmi/widgets_common.ysl2	Thu Jun 04 11:14:21 2020 +0200
@@ -67,6 +67,7 @@
     class Widget {
         offset = 0;
         frequency = 10; /* FIXME arbitrary default max freq. Obtain from config ? */
+        unsubscribable = false;
         constructor(elt_id,args,indexes,members){
             this.element_id = elt_id;
             this.element = id(elt_id);
@@ -77,7 +78,7 @@
 
         unsub(){
             /* remove subsribers */
-            for(let index of this.indexes){
+            if(!this.unsubscribable) for(let index of this.indexes){
                 let idx = index + this.offset;
                 subscribers[idx].delete(this);
             }
@@ -88,14 +89,14 @@
             /* set the offset because relative */
             this.offset = new_offset;
             /* add this's subsribers */
-            for(let index of this.indexes){
+            if(!this.unsubscribable) for(let index of this.indexes){
                 subscribers[index + new_offset].add(this);
             }
             need_cache_apply.push(this); 
         }
 
         apply_cache() {
-            for(let index of this.indexes){
+            if(!this.unsubscribable) for(let index of this.indexes){
                 /* dispatch current cache in newly opened page widgets */
                 let realindex = index+this.offset;
                 let cached_val = cache[realindex];