linkId: fix multi linkId event chains; fix linkId sync not triggering prop updates

This commit is contained in:
jean-emmanuel 2018-08-07 20:26:15 +02:00
parent 32eb431da1
commit 07e3ad7fd7
2 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,11 @@
# Changelog
## 0.36.0
- bug fixes
- `linkId` synchronizations now correctly trigger property updates
- widgets with multiple `linkId` are now properly handled
## 0.35.0
- main

View file

@ -13,6 +13,9 @@ var WidgetManager = class WidgetManager extends EventEmitter {
this.idRoute = {}
this.linkIdRoute = {}
this.linkIdLock = []
this.linkIdLockDepth = 0
this.scrollingWidgets = []
this.preArgsSeparator = '||||'
@ -34,6 +37,9 @@ var WidgetManager = class WidgetManager extends EventEmitter {
if (linkId) {
if (!Array.isArray(linkId)) linkId = [linkId]
linkId = linkId.map(x=>x.replace(/^>>\s*/, '')).filter(x=>x.indexOf('<<') < 0)
linkId = linkId.filter(x=>this.linkIdLock.indexOf(x)<0)
this.linkIdLock = this.linkIdLock.concat(linkId)
this.linkIdLockDepth++
}
var widgetsById = this.getWidgetById(id),
@ -56,11 +62,18 @@ var WidgetManager = class WidgetManager extends EventEmitter {
let v = widget.getValue()
for (let i in widgetsByLinkId) {
if (widgetsByLinkId[i] !== widget) {
widgetsByLinkId[i].setValue(v,{send:options.send,sync:false})
widgetsByLinkId[i].setValue(v,{send: options.send,sync: true})
}
}
}
if (linkId && this.linkIdLockDepth) {
this.linkIdLockDepth--
if (!this.linkIdLockDepth) {
this.linkIdLock = []
}
}
}
createAddressRef(widget, preArgs, address) {