osc-receiver: allow non string values

This commit is contained in:
jean-emmanuel 2018-06-28 13:08:43 +02:00
parent 96d751849d
commit 75d0e99aa5
3 changed files with 13 additions and 4 deletions

View file

@ -3,7 +3,7 @@
## 0.33.0
- bug fixes
- osc receivers not properly unregistered when widgets are recreated (memory leak)
- osc receivers: not properly unregistered when widgets are recreated (memory leak); allow non-string values (eg. objects)
- widgets
- **new** generic `matrix` widget
- fader: restore right-click focusing the input in compact mode (mouse only)

View file

@ -4,7 +4,12 @@ module.exports = class OscReceiver {
constructor(address, value, parent, propName) {
this.value = value
try {
this.value = JSON.parse(value)
} catch (err) {
this.value = value
}
this.parent = parent
this.propName = propName
this.bindedCallback = this.callback.bind(this)
@ -37,7 +42,12 @@ module.exports = class OscReceiver {
var val = args.slice(preArgs.length)
if (val.length < 2) val = val[0]
if (val !== this.value) {
this.value = val
try {
this.value = JSON.parse(val)
} catch (err) {
this.value = val
}
console.log(this.value)
this.parent.updateProps([this.propName], this.parent)
}
}

View file

@ -357,7 +357,6 @@ class Widget extends EventEmitter {
}
var r = this.oscReceivers[address].value
r = typeof r != 'string' ? JSON.stringify(r) : r
var varname = 'VAR_' + varnumber
varnumber++