Skip to content

components/worker-component

A component that owns one browser Worker built from bundled source and calls it through a typed request/response channel.

Class Description
WorkerCallError The error a call rejects with when the worker’s handler failed. It carries the worker-side name, message and stack, because an Error loses its class across the worker boundary.
WorkerComponent Owns one Worker for the component’s lifetime. On load it turns the bundled source into a Blob URL and starts the worker; on unload it terminates the worker, revokes the URL and rejects every pending call. Add it as a child of the plugin (or of any component), so the worker never outlives what uses it. The worker entry point calls exposeWorkerApi from @mnaoumov/obsidian-lib/worker-protocol, and WorkerComponent.call reaches its handlers by name, typed by TApi.
Interface Description
WorkerComponentCallOptions Options of WorkerComponent.call.
WorkerComponentConstructorParams Parameters of WorkerComponent.
Type Description
WorkerMethod The method names of a WorkerApi.
WorkerMethodResult The resolved result type of a worker method.