@@ -126,9 +126,10 @@ const connect = options => new Promise((resolve, reject) => {
126
126
127
127
let valueToSend = { } ;
128
128
let propertyNameKeyPrevious = '' ;
129
+ let propertyNameKey = '' ;
129
130
propertyValue . forEach ( ( p ) => {
130
131
// Support cbor labels
131
- let propertyNameKey = p . n !== undefined ? p . n : p [ '0' ] ;
132
+ propertyNameKey = p . n !== undefined ? p . n : p [ '0' ] ;
132
133
const propertyNameKeySplit = propertyNameKey . split ( ':' ) ;
133
134
134
135
const valueKey = p . v !== undefined ? 'v' : '2' ;
@@ -148,8 +149,10 @@ const connect = options => new Promise((resolve, reject) => {
148
149
if ( propertyNameKeyPrevious === '' ) {
149
150
propertyNameKeyPrevious = propertyNameKeySplit [ propertyNameId ] ;
150
151
}
151
- if ( propertyNameKeyPrevious !== propertyNameKey && propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ) {
152
- propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ( valueToSend ) ;
152
+ if ( propertyNameKeyPrevious !== propertyNameKey ) {
153
+ if ( propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ) {
154
+ propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ( valueToSend ) ;
155
+ }
153
156
propertyNameKeyPrevious = propertyNameKey ;
154
157
valueToSend = { } ;
155
158
}
@@ -160,8 +163,8 @@ const connect = options => new Promise((resolve, reject) => {
160
163
valueToSend [ attributeName ] = value ;
161
164
}
162
165
} ) ;
163
- if ( valueToSend !== { } && propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ) {
164
- propertyCallback [ msg . topic ] [ propertyNameKeyPrevious ] ( valueToSend ) ;
166
+ if ( valueToSend !== { } && propertyCallback [ msg . topic ] [ propertyNameKey ] ) {
167
+ propertyCallback [ msg . topic ] [ propertyNameKey ] ( valueToSend ) ;
165
168
}
166
169
}
167
170
} ;
0 commit comments