New MooTools Plugin: Request.Queue
Aaron Newton announced the availability of Request.Queue to queue up multiple requests (The Request class lets you handle more than one request but this plugin comes in handy when you have multiple instances of the Request class or its subclasses) and have them run one, two or three (depends on how many you want) at a time. He also puts together a code snippet to show how it would look if we wanted the queue to process one Request at a time.
Here is the code example from the clientside blog:
var num1 = new Request({ url: '/wiki/simple.php', data: {num: 1, sleep: 1}, method: 'get', onComplete: function(response){ console.log(response) } }); var num2 = new Request({ url: '/wiki/simple.php', data: {num: 2, sleep: 1}, method: 'get', onComplete: function(response){ console.log(response) } }); var num3 = new Request({ url: '/wiki/simple.php', data: {num: 3, sleep: 1}, method: 'get', onComplete: function(response){ console.log(response) } }); var myQueue = new Request.Queue(); //you can add them one at a time myQueue.addRequest('num1', num1); //or in a single call myQueue.addRequests({ num2: num2, num3: num3 }); num1.send(); num2.send(); num3.send();
















Stumble it!



























Leave a Reply