This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 15094 - When creating a worker, it should be possible to assign some arguments to the constructor, or pass an init object like so: var worker = new Worker("someurl.js", { someData: "1234" }); The object passed could be made available as the current context (this.
Summary: When creating a worker, it should be possible to assign some arguments to the...
Status: RESOLVED WONTFIX
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Web Workers (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: public-webapps-bugzilla
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-07 00:57 UTC by contributor
Modified: 2011-12-14 00:22 UTC (History)
4 users (show)

See Also:


Attachments

Description contributor 2011-12-07 00:57:42 UTC
Specification: http://www.w3.org/TR/workers/
Multipage: http://www.whatwg.org/C#top
Complete: http://www.whatwg.org/c#top

Comment:
When creating a worker, it should be possible to assign some arguments to the
constructor, or pass an init object like so:

var worker = new Worker("someurl.js", { someData: "1234" });

The object passed could be made available as the current context
(this.someData) or as a global variable with a predefined name.


Posted from: 84.48.203.37
User agent: Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; nb-no) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5
Comment 1 Jonas Sicking (Not reading bugmail) 2011-12-07 01:16:19 UTC
Oooh, I like this idea.

Basically it's syntax sugar for creating a worker and then posting a message to it. But it allows the data to be there while the initial worker body is running which is nice.
Comment 2 Ian 'Hixie' Hickson 2011-12-09 23:08:37 UTC
This saves like 3 lines of code, is it really that helpful?

var worker = new Worker("someurl.js");
worker.postMessage({somData: "1234"});

// someurl.js:
onmessage = function (event.data) {
  // whatever your worker would have been;
  // initial data is in event.data
}
Comment 3 Ian 'Hixie' Hickson 2011-12-14 00:22:12 UTC
Doesn't seem compelling. Please don't hesitate to reopen if I've missed something obvious here.