DEV Community

Discussion on: How to pass function to Web Workers

Collapse
 
alekseiberezkin profile image
Aleksei Berezkin

Passing serialized functions around may be not secure. It's better to define all needed functions inside the worker.

Collapse
 
elisiondan profile image
Daniel Charvát

I generally agree. However, I'm currently working on a reusable Vue component that offloads heavy calculations to workers. I'm aiming at providing a simple way to pass additional evaluators, functions, so that anyone who uses the component can easily extend it's function without having to manually play around with workers.

For internal development, definitely, I'd define everything there too.