Thread

Run a CPU intensive task in the background, with out locking the main UI interface.

This will run in a separate JS Runtime, which requires some cpu and memory overhead.

var t = new Thread(function(foo){
   // something loud and heavy
});
t.oncomplete = function(event){
   // executed when the job is done
   console.log(event.data);
};
t.start("bar"); // start the new job with "bar" as a parameter.

start(args=T)

Start a tread.

Arguments:
args (Any)

function arguments

Event: oncomplete(event)

Function that will be called when the thread is complete.

Parameters:
event (Object)

event object

data (String)

The message data

Event: onmessage(event)

Function that will be called when the thread posts a message.

Parameters:
event (Object)

event object

data (String)

The message data


Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!