After 7+ hours of listening to Crockford on JavaScript and some other lectures, I've decided to write my own JS Framework for a current project. As I'm working through various bits I discovered what appears to be a bug in Firefox 3.6.

This fires twice, unexpectedly:
function all(){
var promise = make_promise();
// Simulate async call from some source
setTimeout(function(){
promise.fulfill(fixture);
}, 3000);
return promise;
}

This fires just once, as expected:
function all(){
var promise = make_promise();
// Simulate async call from some source
function fulfill(){
promise.fulfill(fixture);
}
setTimeout(fulfill, 3000);
return promise;
}
I'm seeing a smilar behavior but your solution doesn't work in my tests.

Attempting to use global functions didn't work either for me.

There are other work arounds.

I suggest using Doug Crockfords "once" on the function - if you in fact only need to use it once.
http://gist.github.com/373144

If the issue is that the function shouldn't be called twice before the first finishes, you can adapt it.

Feel free to pop in #ujsug (IRC) or send a message to our google group if you want to discuss the issue.


By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )



Published

2010-4-12



Buy me a coffeeBuy me a coffee


  73% of Goal Reached


Want more like this?