You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below code uses dedicated worker, in the worker code.
const ctx: Worker = self as any;
ctx.addEventListener('message', (e) => {
// console.log(e)
if (e.data === 'do some work') {
console.log('Worker is about to start some work');
let count: number = 0;
for (let i: number = 0; i < 1000; i++) {
count += i;
}
ctx.postMessage({ message: count });
}
})
where the calling code is:
let worker: Worker = new Worker('worker.js');
worker.postMessage('do some work');
It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on TypeScript itself, rather than a general forum for programmers using TypeScript to get help or ask questions.
You can ask questions on sites like Stack Overflow. We are not able to provide one-on-one support on the issue tracker. Next time, please read the issue template carefully - it has important information on what kinds of reports can be acted on here, as well as links to useful TypeScript resources. Thanks!
Below code uses dedicated worker, in the worker code.
where the calling code is:
and
tsconfig.json
is:Trying to execute the same code using
let worker: SharedWorker = new SharedWorker('worker.js');
but got the errorCannot find name 'SharedWorker'
here is the folder structure
How to use
SharedWorker
in place of dedicated worker?The text was updated successfully, but these errors were encountered: