Skip to content
Browse files

[fix] delay arguments[0] callback until .online has been set

  • Loading branch information...
1 parent d2a7469 commit ed737386768b1a65e414eb3566907de3e69d38f1 @AndreasMadsen committed Mar 6, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/core/requester.js
View
11 lib/core/requester.js
@@ -32,11 +32,6 @@
var layerCollection = exports.layers[layerName];
this.layer = new layerCollection.Requester(object);
- // add lisenter to connect stack
- if (this.lisenter) {
- this.layer.once('connect', this.lisenter);
- }
-
// keep online state
this.layer.on('connect', function () {
self.online = true;
@@ -49,6 +44,12 @@
this.layer.on('close', this.emit.bind(this, 'close'));
this.layer.on('error', this.emit.bind(this, 'error'));
this.layer.on('connect', function () {
+
+ // execute connect callback given by arguments[0] if exist
+ if (self.lisenter) {
+ self.lisenter(self.remote);
+ }
+
self.emit('connect', self.remote);
});

0 comments on commit ed73738

Please sign in to comment.
Something went wrong with that request. Please try again.