Open kubijo opened 1 month ago
It does not do it automatically because every callback requires creating a new proxy that holds on to the proxied value, which is basically a memory leak.
If you want to automatically proxy callbacks, you can use transfer handlers. The example for in the README shows how to automatically proxy events and you can use the exact same technique for functions.
I was curious about this as well. Mainly because callbacks can’t be sent natively so we’ll always need to proxy them, which seems redundant IMO.
Yeah, then again... there is a strong chance for memory leaks with callbacks in general. I think I'm gonna in the end rather use some observed triggers in indexeddb (which is part of my whole setup for the project)
Out of curiosity, why doesn't
comlink
automatically proxy callbacks out of the box or at least give an opt-in for that?I have been able to achieve it in the following way…
Am I missing something important here?