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

opera or xhr-polling quirks #55

Closed dvv closed 13 years ago

dvv commented 13 years ago

Hi!

The following chunk of code:

// ...
now.ready(function() {
  console.log('NOW READY');
  var operaSucksOrXHRPollingSucksOrWhat = false;
  now.getContext(id, function(response) {
    if (operaSucksOrXHRPollingSucksOrWhat) return;
      operaSucksOrXHRPollingSucksOrWhat = true;
      console.log('GOT CONTEXT', response);
      // ...

illustrates the problem I previously described in #39

now.ready indeed is called once, but without the fuser I get two GOT CONTEXT lines in the console, which means the callback for my custom now.getContext is called twice. This quirk I noticed only when testing in Opera which fallbacks to xhr-polling socket.io method.

Can anyone confirm this behavior?

TIA, --Vladimir

ericz commented 13 years ago

I have reproduced it.

It connects to the server twice, and thus all actions get doubled. Lets see whats causing it....

dvv commented 13 years ago

Interesting to check, whether it's xhr-polling, or Opera, who's failing?

ericz commented 13 years ago

Actually it seems like this is an issue with the internal dependency loaded callback being called twice.

This issue should be fixed in master.

dvv commented 13 years ago

Worth to mention: if the server downs and ups, now.ready is re-called if reconnection enabled. So anyone who puts singleton stuff into now.ready (my situation: Backbone.history.start()), be warned that you shouldn't.

ericz commented 13 years ago

Hmm I should get that in the documentation

juzerali commented 12 years ago

@ericz: Is this resolved or just closed? Coz I am facing this issue.