Is there any place I can find an example of writing a web worker in typescript? I have created a new file myworker.ts that looks like below:
/// <reference path="IWorkerMessages.ts" />
self.onmessage = (ev: MessageEvent) =>
{
var data = <IWorkerIncoming>ev.data;
}
// I get a compiler error while trying to define self.deserialize
self.deserialize = (data: IWorkerIncoming) =>
{
}
could the file be refactored to something like
class MyWorker implements Worker
{
}
_Edited by @DanielRosenwasser to add code fences._
Webworkers in TypeScript work the same as in JavaScript. The only thing in question is where to get the typings from, which is our lib.webworker.d.ts
. Take a look at http://blog.scottlogic.com/2015/08/10/ts-vs-proj.html and #4855.
In the future, StackOverflow is a better venue for these types of questions - just as a heads up.
Thanks for the link. Actually I found it more confusing than helpful to be honest. I am not using any virtual projects. Further I am developing a single page app with no MVC. I do my compilation within VS and am not using command line. The problems I am struggling with are:
These sort of questions are probably better asked on Stack Overflow.