So what exactly goes on with this onmessage/postMessage paradigm?
那么这个onmessage/postMessage 范型到底说明了什么?
You can see that the Worker script has its own onmessage function.
可以看到,这个Worker脚本拥有自己的onmessage函数。
Next, for each worker being created, you set its onmessage function.
接下来,针对每个所创建的worker,设置其onmessage函数。
The onmessage handler is what will receive this message; you use a simple closure for it.
onmessage处理器将接收这个消息;我们为它使用了一个简单的闭包。
To pass this data back, the postMessage function is called, which will invoke the onmessage callback function on the worker, as shown back in Listing 9.
为了将此数据传递回去,调用了 postMessage函数,由该函数在这个worker上调用onmessage回调函数,如清单 9中所示。
To receive messages, subscribe to the onMessage event
登记onMessage事件以接收信息
To receive messages, subscribe to the onMessage event
登记onMessage事件以接收信息
应用推荐