使用WebWorker创建http请求

时间:2018-04-15 06:56:12

标签: angular nativescript angular2-nativescript nativescript-angular

我试图使用nativescript网络工作者,但我遇到了问题。 我想使用http角度服务在webWorker.ts中发出http请求 我需要将http角度服务导入worker.ts并在那里使用

我尝试将http服务作为参数发送到worker.ts但是它不起作用,因为它正在初始化服务

我希望代码看起来像那样 worker.ts

require("globals");
(<any>global).onmessage = (msg: any) => {
       (make the httpRequest..... ).subscribe(response=>{
          (<any>global).postMessage(response);
        })

}
你有什么想法我能做到吗?

0 个答案:

没有答案