diff --git a/lib/client.js b/lib/client.js index 3af94fe0..4e3f8112 100644 --- a/lib/client.js +++ b/lib/client.js @@ -78,7 +78,8 @@ p.connect = function() { con.sync(); } }); - + + self.emit('connect'); }); con.on('readyForQuery', function() { diff --git a/lib/index.js b/lib/index.js index 4fe24fe5..60778e0c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ var connect = function(config, callback) { client.connect(); var onError = function(error) { - client.connection.removeListener('readyForQuery', onReady); + client.removeListener('connect', onReady); callback(error); } @@ -30,7 +30,7 @@ var connect = function(config, callback) { //TODO refactor //i don't like reaching into the client's connection for attaching //to specific events here - client.connection.once('readyForQuery', onReady); + client.once('connect', onReady); }