Permalink
Browse files

also remove reconnect listener in .destroy()

  • Loading branch information...
1 parent 813c7de commit 66f18494e209b55dd83cdc1407609ddd1d4e8200 @substack committed May 21, 2012
Showing with 5 additions and 3 deletions.
  1. +4 −2 index.js
  2. +1 −1 package.json
View
@@ -90,7 +90,7 @@ Airport.prototype.connect = function (role, fn) {
});
var pending = false;
- c.on('reconnect', function () {
+ function onreconnect () {
if (!active) return;
if (pending) return;
target.emit('reconnect');
@@ -107,11 +107,13 @@ Airport.prototype.connect = function (role, fn) {
}
});
pending = true;
- });
+ }
+ c.on('reconnect', onreconnect);
var active = true;
c.destroy = function () {
active = false;
+ c.removeListener('reconnect', onreconnect);
};
return c;
View
@@ -1,7 +1,7 @@
{
"name" : "airport",
"description" : "role-based port management for upnode",
- "version" : "0.3.7",
+ "version" : "0.3.8",
"repository" : {
"type" : "git",
"url" : "git://github.com/substack/airport.git"

0 comments on commit 66f1849

Please sign in to comment.