简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM