Skip to content

Commit

Permalink
Hack to prevent callback from being called multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
sean9keenan committed May 23, 2017
1 parent 954783e commit fee5fa0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,15 @@ function BigAssFanAccessory(log, config, existingAccessory) {

BigAssFanAccessory.prototype.getStateFactory = function(propertyToWrap, subProperty, outputMapping) {
return function(callback) {
// TODO: Determine why update can callback multiple times
// This temporarily prevents multiple calls to the callback
var callbackCalled = false;
this.myBigAss[propertyToWrap].update(subProperty, function(err, value) {
var returnVal = outputMapping(value);
callback(err, returnVal);
if (!callbackCalled) { // TODO: remove after bug is found
callbackCalled = true;
callback(err, returnVal);
}
});
}
}
Expand Down

0 comments on commit fee5fa0

Please sign in to comment.