UNPKG

@osaedasia/oresume

Version:

A user-friendly library for generating complete Single Page Applications (SPAs)

32 lines (31 loc) 1.29 kB
import { ITaskService } from "../../domain/definitions/interfaces/ITaskService"; import { ProgressMessage } from "./messages/ProgressMessage"; /** * A service that utilizes a Web Worker instance to offload background tasks * and handle execution of tasks, termination, and progress updates. * @template TInput The type of input data sent to the worker * @template TOutput The type of output data received from the worker * @implements {ITaskService<TInput, TOutput>} */ export declare class WorkerService<TInput, TOutput> implements ITaskService<TInput, TOutput> { /** * The Worker instance responsible for executing tasks in a separate thread. * Handles computations and communication without blocking the main thread. */ private readonly _worker; /** * Callback function for handling progress updates during task execution. */ private progressCallback?; /** * Creates a new WorkerService instance. * @param {URL} workerScriptPath The URL of the worker script to be loaded */ constructor(workerScriptPath: URL); /** @inheritDoc */ execute(data: TInput): Promise<TOutput>; /** @inheritDoc */ terminate(): void; /** @inheritDoc */ onProgress(callback: (data: ProgressMessage) => void): void; }