Rxova
Skip to content

SharedWorkerTransportOptions

optional factory?: (url, name) => SharedWorkerLike;

Constructs the worker. Only tests should pass this; the default is globalThis.SharedWorker.

ParameterType
urlstring
namestring

SharedWorkerLike


optional name?: string;

Distinguishes workers loaded from the same script. Defaults to the bus name, which is what makes two buses on one origin independent.


url: string | URL;

The relay script. A URL rather than a string in the common case, because new URL('./relay.js', import.meta.url) is what survives a bundler.

It must be a stable URL, and that is the whole reason this option exists rather than the library inlining a worker from a Blob the way it could for a dedicated one: a SharedWorker’s identity is its script URL plus its name, and every tab that builds its own Blob URL gets its own worker. Inlining would produce N private workers that share nothing — the failure this transport exists to prevent, wearing the costume of a fix.