This is an odd problem. I have a client object that I am building up using Crockford-esque public/private members:
var client = function() {
var that, remote_data, other_data;
// add public interface
that.doStuff = function(){...}
// wait for remote resources to load
remote_data = jsonRequest1();
other_data = jsonRequest2();
return that;
};
The problem I'm having is that I need to load some remote JSON resources prior to returning the new 'that' object (which signals a ready client). Data is returned asynchronously (obviously), and I am setting boolean variables to indicate when each remote resource has returned.
I've thought about doing something like the following:
return whenInitialized(function() { return that; });
The whenInitialized function returns whether or not both of the boolean flags are true. I'd use this with a combination of setInterval, but I am sure this won't work.
Would appreciate your suggestions.
In a very simple jQuery modal, I close the modal by clicking on CLOSE as $('#close').click(function(e) { e.preventDefault(); $('#overlay, #alertModalOuter').fadeOut(400, function() { $(this)....
In a very simple jQuery modal, I close the modal by clicking on CLOSE as $('#close').click(function(e) { e.preventDefault(); $('#overlay, #alertModalOuter').fadeOut(400, function() { $(this)....
I'm using Cleditor http://premiumsoftware.net/cleditor/docs/GettingStarted.html. I want to get the value on keyup and insert the text into another div. cleditor comes with change() event that i'm ...
I'm using Cleditor http://premiumsoftware.net/cleditor/docs/GettingStarted.html. I want to get the value on keyup and insert the text into another div. cleditor comes with change() event that i'm ...
Browsing Hacker News and I come across http://streamjs.org/ which is an implementation of a lazy evaluated collection in Javascript. One of the examples is this: function ones() { return new ...
Browsing Hacker News and I come across http://streamjs.org/ which is an implementation of a lazy evaluated collection in Javascript. One of the examples is this: function ones() { return new ...
This is code from a book I have explaining recursion. The problem is that I don't understand the steps taken by the program: var hanoi = function(disc,src,aux,dst) { if (disc > 0) { ...
This is code from a book I have explaining recursion. The problem is that I don't understand the steps taken by the program: var hanoi = function(disc,src,aux,dst) { if (disc > 0) { ...