1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #563 from emiloberg/master

Fixes bug that prevented unsubscribe from WebSockets, browser side. Fixes node-red/node-red/#562
This commit is contained in:
Nick O'Leary 2015-02-15 21:54:48 +00:00
commit a808cb44c2

View File

@ -95,15 +95,15 @@ RED.comms = (function() {
} }
function unsubscribe(topic,callback) { function unsubscribe(topic,callback) {
if (subscriptions.topic) { if (subscriptions[topic]) {
for (var i=0;i<subscriptions.topic.length;i++) { for (var i=0;i<subscriptions[topic].length;i++) {
if (subscriptions.topic[i] === callback) { if (subscriptions[topic][i] === callback) {
subscriptions.topic.splice(i,1); subscriptions[topic].splice(i,1);
break; break;
} }
} }
if (subscriptions.topic.length === 0) { if (subscriptions[topic].length === 0) {
delete subscriptions.topic; delete subscriptions[topic];
} }
} }
} }