Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 270
J. Frankenstein Avatar asked Oct 22 '22 12:10

J. Frankenstein


1 Answers

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.

like image 99
Kyaw Tun Avatar answered Nov 09 '22 09:11

Kyaw Tun