问题
I have an ember application that I create like this:
window.App = Ember.Application.create({});
I want to do some background processing on a web worker.
How can I get access to the window object or some other global object in the separate web worker thread?
回答1:
Short answer. You can't.
The only resources available to web workers are that which they load from JavaScript files using importScripts()
or anything that is passed to them via postMessage()
.
You can however now pass Objects to them. They are serialized and de-serialized to JSON automatically.
Also, there is no access to local storage from the Worker.
来源:https://stackoverflow.com/questions/10945672/web-workers-and-accessing-object-attached-to-the-window-object