Skip to content

Specify Transferable Objects #13

Open
@chrism6475

Description

@chrism6475

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions