Updated:
I have typescript classes that have functions in them and I can pass those classes using postMessage fine. But the following class with a variable that is function fails.
For the code below calling doitSuccess() succeeds. Calling doitFails() throws a "can not serialize" exception. I have also successfully passed objects that are typescript classes that have functions in the class. What seems to be the problem is a member variable assigned a function.
Any idea why?
Update: It might be what is discussed in this post.
function defaultToString(item: any): string {
return "dave";
}
export class WorkerApi {
private worker:Worker;
constructor () {
worker = new Worker("my-worker.js");
}
public doitFails() : void {
var ll = { name : "dave", toStr: defaultToString};
this.worker.postMessage(ll);
}
public doitSuccesss() : void {
var ll = { name : "dave"};
this.worker.postMessage(ll);
}
}