4 ms·
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
by emehrkay 15y ago
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/ 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);
});