将 REST 请求中的大数据 JSON 反序列化为对象而不锁定浏览器?
在富互联网应用程序中:
- 用户请求资源
- 服务器以巨大的 JSON 响应进行响应
- 客户端(在浏览器中运行)必须处理 JSON,将其转换为构成应用程序状态的许多对象。
第 3 步非常密集,可能会导致浏览器锁定。我正在考虑使用网络工作者,但我认为他们可能不适合这项任务。
据我了解,工人纯粹以文本或 JSON 形式传递消息。因此,虽然 Web Worker 可以接受消息(“请在该 URL 获取资源”),但 Worker 可以检索大型 JSON 响应,甚至将其反序列化为构成应用程序状态的许多对象,但是无法通过消息传递构造将对象(各种类的实例)传递回主进程。正确的?或者我错过了什么?
如何允许浏览器内客户端将大数据反序列化为对象而不影响用户体验(锁定浏览器)?如果网络工作人员不在,是否就可以使用计时器(用于时间切片)?
In a rich internet app:
- User requests a resource
- Server responds with a huge JSON response
- Client (running in browser) must process the JSON converting it to the many objects which make up the application state.
Step 3 is intensive and can cause the browser to lock. I was thinking about using web workers but I think they may not be suited for the task.
As I understand workers, they pass messages purely as text or JSON. So while it would be possible for the web worker to accept a message ("please fetch the resource at this URL") the worker could then retrieve the large JSON response and even deserialize it into the many objects making up the app state, but there would be no way to pass objects (instances of various classes) back to the main process via the message passing construct. Right? Or am I missing something?
How would one allow an in-browser client to deserialize big data into objects without compromising the user experience (locking the browser)? If web workers are out, does that leave using timers (for timeslicing)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JavaScript 如何减慢网络速度(以及如何应对)
How JavaScript is Slowing Down the Web (And What To Do About It)