Web工作者和访问连接到窗口对象的对象 [英] Web workers and accessing object attached to the window object

查看:85
本文介绍了Web工作者和访问连接到窗口对象的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  window.App = Ember.Application.create({} ); 

我想在web worker上做一些后台处理。



如何在单独的web worker线程中访问窗口对象或某个其他全局对象?

解决方案

<简答。您不能。



Web工作人员可用的唯一资源是使用 importScripts()或任何通过 sendmessage()传递给它们的任何东西。

然后你可以传递对象给它们。它们会被自动序列化并反序列化为JSON。

此外,Worker不能访问本地存储。


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?

解决方案

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 sendmessage().

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.

这篇关于Web工作者和访问连接到窗口对象的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆