category | related |
---|---|
Browser |
useWebWorkerFn |
Simple Web Workers registration and communication.
import { useWebWorker } from '@vueuse/core'
const { data, post, terminate, worker } = useWebWorker('/path/to/worker.js')
State | Type | Description |
---|---|---|
data | Ref<any> |
Reference to the latest data received via the worker, can be watched to respond to incoming messages |
worker | ShallowRef<Worker | undefined> |
Reference to the instance of the WebWorker |
Method | Signature | Description |
---|---|---|
post | (message: any, transfer: Transferable[]): void (message: any, options?: StructuredSerializeOptions | undefined): void |
Sends data to the worker thread. |
terminate | () => void |
Stops and terminates the worker. |