Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

listen for the right events

  • Loading branch information...
commit 696e5289f088b14a3a57549413468cf1252796cc 1 parent acb4825
@substack authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 index.js
View
10 index.js
@@ -26,6 +26,8 @@ var airport = module.exports = function (ports) {
};
function Airport (ports, cons) {
+ports.on('connect', function () { console.error('CONNECT') });
+ports.on('disconnect', function () { console.error('DISCONNECT') });
this.ports = ports;
this.cons = cons;
}
@@ -60,8 +62,8 @@ Airport.prototype.connect = function (opts, fn) {
queue.forEach(function (cb) { res(cb) });
queue = [];
}
- if (this._ondown) ports.removeListener('down', this._ondown);
- ports.on('down', ondown);
+ if (this._ondown) ports.removeListener('disconnect', this._ondown);
+ ports.on('disconnect', ondown);
this._ondown = ondown;
function connector (service, cb) {
@@ -108,11 +110,11 @@ Airport.prototype.connect = function (opts, fn) {
if (!active || !pending) return;
ports.get(role, withResults);
}
- ports.once('up', onup);
+ ports.once('connect', onup);
ports.get(role, withResults);
function withResults (ps) {
- ports.removeListener('up', onup);
+ ports.removeListener('connect', onup);
if (!active) return;
pending = false;
Please sign in to comment.
Something went wrong with that request. Please try again.