Skip to content
1 min read · 103 words

Type Alias: WorkerResolver

ts
type WorkerResolver = (ctx: {
  spec: IsolatedServiceSpec;
}) => BrowserWorker | Promise<BrowserWorker>;

Defined in: src/batteries/isolation/browser.ts:98

Bring-your-own Worker spawner — the first-class seam for handing spawnIsolated/createWorkerTransport a Worker constructed however the caller's bundler/pooling strategy demands (a new Worker(new URL(...), import.meta.url) Vite/webpack pattern, a worker pool that recycles threads, a test harness's Blob-URL worker, etc.). Called once per connect() (including every recycle()) — see createWorkerTransport's remarks for why this makes a resolver the SINGLE source of Worker creation for a given transport.

Parameters

ParameterType
ctx{ spec: IsolatedServiceSpec; }
ctx.specIsolatedServiceSpec

Returns

| BrowserWorker | Promise<BrowserWorker>