angular2-web-worker icon indicating copy to clipboard operation
angular2-web-worker copied to clipboard

Specify Transferable Objects

Open chrism6475 opened this issue 7 years ago • 0 comments

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.

chrism6475 avatar Feb 08 '18 22:02 chrism6475