useWebWorker
Simple Web Workers registration and communication.
Related Functions
Try out the high-level useWebWorkerFn
Usage
import { useWebWorker } from 'vue-use-web'
const { data, post, terminate } = 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 |
Method | Signature | Description |
---|---|---|
post | (data: any) => void | Sends data to the worker thread. |
terminate | () => void | Stops and terminates the worker. |
Type Declarations
/**
* Simple Web Workers registration and communication.
*
* @see /useWebWorker
* @param url
* @param workerOptions
* @param options
*/
export declare function useWebWorker(
url: string,
workerOptions?: WorkerOptions,
options?: ConfigurableWindow
): {
data: Ref<any>
post: {
(message: any, transfer: Transferable[]): void
(message: any, options?: PostMessageOptions | undefined): void
}
terminate: () => void
worker: Ref<Worker | undefined>
}