SharedWorker

open class SharedWorker(scriptURL: TrustedScriptURL, options: String = definedExternally) : EventTarget, AbstractWorker(source)

The SharedWorker interface represents a specific kind of worker that can be accessed from several browsing contexts, such as multiple windows or iframes. Shared workers implement a different interface than dedicated workers, have a different global scope (SharedWorkerGlobalScope), and their constructor is not exposed in DedicatedWorkerGlobalScope, so they cannot be instantiated from dedicated workers.

MDN Reference

Constructors

Link copied to clipboard
constructor(scriptURL: TrustedScriptURL, options: String = definedExternally)
constructor(scriptURL: TrustedScriptURL, options: WorkerOptions)
constructor(scriptURL: String, options: String = definedExternally)
constructor(scriptURL: String, options: WorkerOptions)
constructor(scriptURL: URL, options: String = definedExternally)
constructor(scriptURL: URL, options: WorkerOptions)

Properties

Link copied to clipboard

The port property of the SharedWorker interface returns a MessagePort object used to communicate and control the shared worker.

Functions

Link copied to clipboard
open fun dispatchEvent(event: Event): Boolean
Link copied to clipboard