Using Webworkers in angular app (service worker cache access of data in angular-cli)
问题 I wish to run an function (in the background) using a worker. The data comes from a http request. I am using a mock calculation (e.data[0] * e.data[1] * xhrData.arr[3]) (replaced by a function returning the actual algo result) as below: var ajax = function() { var prom = new Promise(function(resolve, reject){ if (!!XMLHttpRequest) { var xhttp = new XMLHttpRequest(); xhttp.onload = function () { if (this.readyState == 4 && this.status == 200) { resolve(JSON.parse(this.responseText)); } }; //