angular2-web-worker
angular2-web-worker copied to clipboard
Specify Transferable Objects
Is there a way to modify the post message to include the list of transferable objects. I've changed the create Promise for worker function to specify the transferable object as such:
private createPromiseForWorker<T>(worker: Worker, data: any) {
return new Promise<T>((resolve, reject) => {
worker.addEventListener('message', (event) => resolve(event.data));
worker.addEventListener('error', reject);
worker.postMessage(data, [data]); //add transferable object
});
}
However, this method produces a data clone error in the console.
I'm trying to send an array of images to my main thread, so any ideas on how to support this functionality would be great.
Thanks.