76 Object.keys(members).forEach(prop => this[prop]=members[prop]); |
76 Object.keys(members).forEach(prop => this[prop]=members[prop]); |
77 } |
77 } |
78 |
78 |
79 unsub(){ |
79 unsub(){ |
80 /* remove subsribers */ |
80 /* remove subsribers */ |
81 if(!this.unsubscribable) for(let index of this.indexes){ |
81 if(!this.unsubscribable) |
82 let idx = index + this.offset; |
82 for(let i = 0; i < this.indexes.length; i++) { |
83 subscribers[idx].delete(this); |
83 let index = this.indexes[i]; |
84 } |
84 if(this.relativeness[i]) |
|
85 index += this.offset; |
|
86 subscribers[index].delete(this); |
|
87 } |
85 this.offset = 0; |
88 this.offset = 0; |
86 } |
89 this.relativeness = undefined; |
87 |
90 } |
88 sub(new_offset=0){ |
91 |
89 /* set the offset because relative */ |
92 sub(new_offset=0, relativeness){ |
90 this.offset = new_offset; |
93 this.offset = new_offset; |
|
94 this.relativeness = relativeness; |
91 /* add this's subsribers */ |
95 /* add this's subsribers */ |
92 if(!this.unsubscribable) for(let index of this.indexes){ |
96 if(!this.unsubscribable) |
93 subscribers[index + new_offset].add(this); |
97 for(let i = 0; i < this.indexes.length; i++) { |
94 } |
98 let index = this.indexes[i]; |
|
99 if(relativeness[i]) |
|
100 index += new_offset; |
|
101 subscribers[index].add(this); |
|
102 } |
95 need_cache_apply.push(this); |
103 need_cache_apply.push(this); |
96 } |
104 } |
97 |
105 |
98 apply_cache() { |
106 apply_cache() { |
99 if(!this.unsubscribable) for(let index of this.indexes){ |
107 if(!this.unsubscribable) for(let index of this.indexes){ |
105 } |
113 } |
106 } |
114 } |
107 |
115 |
108 get_idx(index) { |
116 get_idx(index) { |
109 let orig = this.indexes[index]; |
117 let orig = this.indexes[index]; |
110 return this.offset ? orig + this.offset : orig; |
118 return this.relativeness[index] ? orig + this.offset : orig; |
111 } |
119 } |
112 change_hmi_value(index,opstr) { |
120 change_hmi_value(index,opstr) { |
113 return change_hmi_value(this.get_idx(index), opstr); |
121 return change_hmi_value(this.get_idx(index), opstr); |
114 } |
122 } |
115 |
123 |