Initial support for dynamic properties
This commit is contained in:
parent
cbb6f8c33e
commit
98f5858b11
10 changed files with 46 additions and 33 deletions
|
@ -14,6 +14,9 @@ class TouchBar extends EventEmitter {
|
|||
this.ordereredItems = []
|
||||
const registerItem = (item) => {
|
||||
this.items[item.id] = item
|
||||
item.on('change', () => {
|
||||
this.emit('change', item.id, item.type)
|
||||
})
|
||||
if (item.child instanceof TouchBar) {
|
||||
item.child.ordereredItems.forEach(registerItem)
|
||||
}
|
||||
|
@ -35,8 +38,9 @@ class TouchBar extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
class TouchBarItem {
|
||||
class TouchBarItem extends EventEmitter {
|
||||
constructor (config) {
|
||||
super()
|
||||
this.id = `${itemIdIncrementor++}`
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +85,16 @@ TouchBar.Label = class TouchBarLabel extends TouchBarItem {
|
|||
constructor (config) {
|
||||
super(config)
|
||||
this.type = 'label'
|
||||
this.label = config.label
|
||||
this._label = config.label
|
||||
}
|
||||
|
||||
set label (newLabel) {
|
||||
this._label = newLabel
|
||||
this.emit('change')
|
||||
}
|
||||
|
||||
get label () {
|
||||
return this._label
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue