useWorker
Use the Worker (opens in a new tab) API to run a script in the background.
Type Definitions
type WorkerHandler = (message: {
data?: any;
error?: unknown;
}) => any;
const useWorker: (args: WorkerOptions & {
script: string | (() => any | Promise<any>);
handler: WorkerHandler;
}) => {
isLoading: boolean;
postMessage<M extends unknown>(message: M, options?: StructuredSerializeOptions): void;
terminate(): void;
};