News for hackers. Stuff that matters.
Re:The Only Reason My App Worked Was Due to a Slow Database by emehrkay on Tuesday April 10, 2012 @05:09PM (#3824440)
I submitted this a few days ago, but he could use a very simple Object Pool to handle this. Set up a pool with 3 or so Ajax request objects and make requests to that pool.

Here is an example where I setup four MooTools Fx.Morph objects. Then I set up 400 divs that whose width will be modified using the next available Fx.Morph object in the queue. It is pretty simple, powerful stuff. Your objects must be reusable though so I dont think jQuery's built-in ajax/animations would work (I use this in "production" with MooTools' Request objects)

http://jsfiddle.net/XkTPJ/11/

you simply get an instance of Pool, add your actions, by calling pool.act(fn). In your callback you'll receive one of the objects in the pool when it is ready. You use it, and when youre done, put it by by calling this.add(obj)

    pool = new Pool();
    pool.add(new ObjectInstance());
    pool.act(function(obj){
         //use obj and put it back
        this.add(obj);
    });

There are no comments on this comment yet.