gd-sprest 9.4.7 → 9.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/helper/methods/webWorker.js +28 -21
- package/build/rest.js +1 -1
- package/dist/gd-sprest.js +1 -1
- package/dist/gd-sprest.min.js +1 -1
- package/package.json +1 -1
|
@@ -2,29 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebWorker = WebWorker;
|
|
4
4
|
// Web Worker
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
callback
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
var _WebWorker = /** @class */ (function () {
|
|
6
|
+
// Constructor
|
|
7
|
+
function _WebWorker(callback, interval) {
|
|
8
|
+
if (interval === void 0) { interval = 1000; }
|
|
9
|
+
var _this = this;
|
|
10
|
+
this._worker = null;
|
|
11
|
+
// Create the worker process
|
|
12
|
+
var blob = new Blob([WorkerCode(interval)], { type: "application/javascript" });
|
|
13
|
+
this._worker = new Worker(URL.createObjectURL(blob));
|
|
14
|
+
// Set the callback method
|
|
15
|
+
this._worker.onmessage = function () {
|
|
16
|
+
// Call the callback method
|
|
17
|
+
callback();
|
|
18
|
+
};
|
|
19
|
+
// Watch the unload event to stop the loop
|
|
20
|
+
window.addEventListener("beforeunload", function () {
|
|
21
|
+
// Stop the loop
|
|
22
|
+
_this.stop();
|
|
23
|
+
_this._worker.terminate();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
22
26
|
// Starts the loop
|
|
23
|
-
|
|
27
|
+
_WebWorker.prototype.start = function () { this._worker.postMessage("start"); };
|
|
24
28
|
// Stops the loop
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
_WebWorker.prototype.stop = function () { this._worker.postMessage("stop"); };
|
|
30
|
+
return _WebWorker;
|
|
31
|
+
}());
|
|
32
|
+
function WebWorker(callback, interval) {
|
|
33
|
+
if (interval === void 0) { interval = 1000; }
|
|
34
|
+
return new _WebWorker(callback, interval);
|
|
28
35
|
}
|
|
29
36
|
// The worker code
|
|
30
37
|
function WorkerCode(interval) {
|
package/build/rest.js
CHANGED