flywave-mapview.workerloader.waitworkerinitialized
Home > @flywave/flywave-mapview > WorkerLoader > waitWorkerInitialized
WorkerLoader.waitWorkerInitialized() method
Waits for successful Web Worker start.
Expects that worker script sends initial message.
If first event is message then assumes that worker has been loaded sussesfully and promise resolves to worker object passed as argument.
If first event is 'error', then it is assumed that worker failed to load and promise is rejected.
(NOTE: The initial 'message' - if received - is immediately replayed using worker's dispatchEvent, so application code can also consume it as confirmation of successful worker initialization.
We must resolve/reject promise at some time, so it is expected that any sane application will be able to load worker code in some amount of time.
Signature:
static waitWorkerInitialized(worker: Worker, timeout: number): Promise<Worker>;
Parameters
Parameter | Type | Description |
|---|---|---|
worker | Worker | [[Worker]] instance to be checked |
timeout | number | timeout in milliseconds, in which worker should set initial message |
Returns:
Promise<Worker>
`Promise` that resolves to `worker` on success