A function for setting up a Web Worker environment before it starts processing jobs. May be sync or async. Worker functions cannot use variables defined outside of their block, because the function code itself is inlined and written to the Web Worker source code.
You should pass any dynamic data that won't change between jobs using initArgs
in configureAndStart,
and parse/use them in the init function.
If you need to store some global state to be used later when processing jobs, you can write a property to self
, which will be a DedicatedWorkerGlobalScope
.
But be careful not to overwrite any browser-initialized properties in there!
Optional
message: TGenerated using TypeDoc
Anything passed as
initArgs
in configureAndStart, withTransferable
objects inlined.