[Bug 15007] Add an API to queue a task

https://www.w3.org/Bugs/Public/show_bug.cgi?id=15007

--- Comment #17 from Simon Pieters <simonp@opera.com> 2011-12-05 10:58:05 UTC ---
Further improved version that allows the browser to GC old MessageChannels:

var queueTask = function(task)
{
    var mc = new MessageChannel();
    var args = [].slice.call(arguments, 1);
    mc.port1.onmessage = function(){ this.onmessage = null; task.apply(task,
args); };
    mc.port2.postMessage(null);
}
queueTask(function(arg) { console.log(arg, this) }, "test");

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Monday, 5 December 2011 10:58:08 UTC