J. Frankenstein
J. Frankenstein

Reputation: 1721

How can I use HTML5 Web Workers with Google Closure Tools?

I need to do some computationally intensive stuff in the background of my app and I've been learning about HTML5 Web Workers. Is there an integrated way to do this with Google Closure Tools? I found gears.Worker but it isn't clear to me whether this class fits the bill nor how to use it. Thanks!

Upvotes: 5

Views: 1451

Answers (1)

Kyaw Tun
Kyaw Tun

Reputation: 13141

Using Web Workers do not need anything special from closure library, except if you want to run without compilation bootstrap/webworkers.js will help. It is used like this

/**
 * Closure dependency management, require only main worker script of un-compiled version.
 */
if (typeof COMPILED == 'undefined') {
  CLOSURE_BASE_PATH = '../../../closure-library/closure/goog/';
  importScripts(
      CLOSURE_BASE_PATH + 'bootstrap/webworkers.js',
      CLOSURE_BASE_PATH + 'base.js',
      CLOSURE_BASE_PATH + 'deps.js',
      '/your-script.js');
} 

gear is used before web storage. I guess it is not very good and ugly.

Upvotes: 3

Related Questions