HTML and CSS Reference
In-Depth Information
In this example, my agreed grammar is all messages are pre-
fixed with an action. This could be log, set, run, etc. What's
important is I now have a way to inspect data that's inside the
worker by sending data to my log function.
It's also useful to be able to poke around inside a worker, some-
thing I've found to be exceptionally useful when experimenting
in JavaScript. In a non-worker environment, I can pop open my
console of choice (Firebug, Dragonfly, etc.,) and from within
there, I would log out and inspect all the properties on the
window object, the document , then their properties, just to see
what's supported and what I can play with. Since a worker is a
closed environment, I would need to do this manually. So one of
the online examples for this topic includes a console that allows
you to inspect a Web Worker and test code inside the worker
and see what it produces. You can see the worker console at ( Figure 10.3 ).
note It's possible for a
worker to get aborted or
terminated through a method
unknown to your code. If your
worker is being killed off by the
browser for some reason, then
the worker.onerror event is
going to fire. If you're closing
the worker manually, you're hav-
ing to do this from within the
worker via .close() so you
have the opportunity to notify
the connected documents that
your worker is closing.
Figure 10.3 A demo console to
inspect inside a Web Worker.
Search WWH ::

Custom Search