new HonestWorkers()
A module allowing developers to benefit from the wonderful Promise interface whilst enjoying the
multi-threaded goodness provided by WebWorkers.
Members
Class
Methods
execute(uid, …args) → {Promise}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uid |
String | A unique name or identifier | |
args |
Any |
<repeatable> |
A list of arguements to be passed |
Returns:
A Promise dependant on the success of the task
- Type
- Promise
register(uid, fn) → {function}
This method will register a new function or task using the supplied UID, provided that that UID has
not previously been used. For convenience, a reference to the newly registered item will be returned.
The function or task must adhere to the formatting in the example provided, and the UID must be a
unique string (in the context of the HonestWorker instance).
Parameters:
Name | Type | Description |
---|---|---|
uid |
String | A unique name or identifier |
fn |
function | A function with no lexical dependance |
Returns:
A reference to the new congifuration object
- Type
- function
Example
honestWorkers.register('myTask', function (done) {
// ... do something snazzy
done()
})