Skip to content
1 min read · 119 words

Function: spawnIsolated()

ts
function spawnIsolated<S>(
  spec: S,
  options: SpawnIsolatedOptions,
): IsolatedService<S>;

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

Sugar for createIsolatedService(spec, createWorkerTransport(spec, options), options) — spawn a real Worker-backed IsolatedService in one call.

Type Parameters

Type Parameter
S extends IsolatedServiceSpec<MethodMap, StreamMap, EventMap>

Parameters

ParameterType
specS
optionsSpawnIsolatedOptions

Returns

IsolatedService<S>

Remarks

The transport-only keys (worker/workerOptions) are stripped before the remaining options reach createIsolatedService — its validator is deliberately strict (unknown keys rejected), accepting only the base IsolatedServiceOptions shape; the transport-only keys were already validated (and consumed) by createWorkerTransport.

Throws

@nhtio/adk/batteries/isolation!E_ISOLATION_UNSUPPORTED_ENV when no browser Worker global is present.

Throws

@nhtio/adk/batteries/isolation!E_INVALID_ISOLATION_OPTIONS when options fails validation.