widgets: solve multi-value-dependency pattern resolution using a single queue instead of timeouts
This commit is contained in:
parent
e2215b865a
commit
8b92400c1e
5 changed files with 41 additions and 26 deletions
|
|
@ -19,6 +19,9 @@ class WidgetManager extends EventEmitter {
|
|||
|
||||
this.preArgsSeparator = '||||'
|
||||
|
||||
this.valueChangeLockDepth = 0
|
||||
this.valueChangeQueue = {}
|
||||
|
||||
this.on('value-changed', this.onChange.bind(this))
|
||||
|
||||
ipc.on('connect', ()=>{
|
||||
|
|
@ -29,8 +32,29 @@ class WidgetManager extends EventEmitter {
|
|||
|
||||
}
|
||||
|
||||
valueChangeLock() {
|
||||
this.valueChangeLockDepth++
|
||||
}
|
||||
|
||||
valueChangeUnlock() {
|
||||
this.valueChangeLockDepth--
|
||||
if (this.valueChangeLockDepth == 0) {
|
||||
for (var h in this.valueChangeQueue) {
|
||||
if (this.valueChangeQueue[h]) this.applyValueChange(this.valueChangeQueue[h])
|
||||
}
|
||||
this.valueChangeQueue = {}
|
||||
}
|
||||
}
|
||||
|
||||
onChange(e) {
|
||||
|
||||
if (this.valueChangeLockDepth === 0) this.applyValueChange(e)
|
||||
else this.valueChangeQueue[e.widget.hash] = e
|
||||
|
||||
}
|
||||
|
||||
applyValueChange(e) {
|
||||
|
||||
var {id, widget, linkId, options} = e
|
||||
|
||||
if (linkId) {
|
||||
|
|
@ -78,6 +102,7 @@ class WidgetManager extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
this.trigger('value-changed-lazy', e)
|
||||
}
|
||||
|
||||
createAddressRef(widget, preArgs, address) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue