Angular CLI中的Web worker

Dip*_*gre 6 javascript multithreading web-worker angular

我一直致力于在Angular app客户端进行大量计算,因为它UI被阻止了.我想Web worker在Angular CLI项目中使用在UI一个线程和重处理中运行background thread.

有没有人有想法

  • 如何处理角度的重计算.
  • 如何使用Web Workers在Angular CLI

一些引用
Angular CLI生成的应用程序与Web Workers
https://github.com/angular/angular-cli/issues/5885

Ala*_*ith 1

您可以使用https://www.npmjs.com/package/angular2-web-worker

将 Web Worker 服务注入到您的构造函数中:

 construtor(private webWorkerService: WebWorkerService){
     this.webWorkerService.run( thing to run goes here );
 }
Run Code Online (Sandbox Code Playgroud)