Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

Accessing reference to now scope causes strange behavior #62

Closed tommedema closed 13 years ago

tommedema commented 13 years ago

When saving a reference to the now scope of a client for later use on the server side, like so:

clients[name] = {now: this.now, connectedClient: null};

rather strange behavior is seen when using this now scope to call another server-sided function

if someone does the following somewhere else:

client1 = clients[someName];
client1.now.someServerNowMethod();

everyone.now.someServerNowMethod = function() {
     //the problem: here, "this" equals the actual now scope, even though it should be this.now.. aka, this.now is undefined when called this method is called in the above way
}

So, "this" equals what should be "this.now" when called like this.

ericz commented 13 years ago

This should've have been fixed in a recent version of the code. I'm going to look into what happened...

tommedema commented 13 years ago

I should mention that I update with NPM.

ericz commented 13 years ago

I have replicated this bug. Fixing...

ericz commented 13 years ago

Found bug. Fixing...

ericz commented 13 years ago

Fixed! Will be pushed to npm in next few hours

tommedema commented 13 years ago

You rock!