GoogleChromeLabs / comlink

Comlink makes WebWorkers enjoyable.
Apache License 2.0
11.3k stars 386 forks source link

Do I need to use transfer inside a proxy? #645

Closed Tsury closed 9 months ago

Tsury commented 1 year ago

Sorry for making an issue - was unable to find an answer.

My main creates a worker, and sends some callback to it wrapped in a proxy. Said callback needs to pass back to main a very big array.

Do I need to transfer the array, even though the callback is a proxy?

Thanks.

benjamind commented 9 months ago

I believe so yes. Any time you pass a value that you want to transfer rather than clone then you'll need to transfer it.