Skip to content

Commit

Permalink
Avoid to register the same listener twice
Browse files Browse the repository at this point in the history
  • Loading branch information
HolgerHees authored and wborn committed Feb 24, 2018
1 parent 9ac0d9f commit d115dde
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion web-src/smarthome-grafana.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ function SmartHomeSubscriber(params) {
throw new Error("addItemListener 'listener' is not a function");
}
if (items[itemName] !== undefined) {
items[itemName].listeners.push(listener);
if( !items[itemName].listeners.includes(listener) ) {
items[itemName].listeners.push(listener);
}
} else {
items[itemName] = {listeners: [listener], value: undefined};
}
Expand Down

0 comments on commit d115dde

Please sign in to comment.