Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 1.62 KB

index.md

File metadata and controls

26 lines (19 loc) · 1.62 KB
category related
Browser
useWebWorkerFn

useWebWorker

Simple Web Workers registration and communication.

Usage

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.