blob: ef0ed8fc704ceaa81f1eef8d4ed75fd041baae6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Entry point for dedicated workers.
self.onmessage = evt => {
try {
const worker = new Worker('load_worker.js');
worker.onmessage = evt => self.postMessage(evt.data);
worker.postMessage(evt.data);
} catch (err) {
self.postMessage('Unexpected error! ' + err.message);
}
};
// Entry point for shared workers.
self.onconnect = evt => {
evt.ports[0].onmessage = e => {
try {
const worker = new Worker('load_worker.js');
worker.onmessage = e => evt.ports[0].postMessage(e.data);
worker.postMessage(evt.data);
} catch (err) {
evt.ports[0].postMessage('Unexpected error! ' + err.message);
}
};
};
|