A polyfill class for SharedWorker, it accepts a URL/string as well as any other options the spec. allows for SharedWorker. It supports all the same methods and properties as the original, except it adds compatibility methods and properties for older browsers that don't support SharedWorker, so, it can switch to normal Workers instead.

Hierarchy (view full)

Implements

Constructors

Properties

ActualWorker: SharedWorker | Worker

The actual worker that is used, depending on browser support it can be either a SharedWorker or a normal Worker.

Accessors

  • get onerror(): ((this: AbstractWorker, ev: ErrorEvent) => any)
  • Is an EventListener that is called whenever an ErrorEvent of type error event occurs.

    Returns ((this: AbstractWorker, ev: ErrorEvent) => any)

      • (this, ev): any
      • Parameters

        Returns any

  • set onerror(value): void
  • Parameters

    • value: ((this: AbstractWorker, ev: ErrorEvent) => any)
        • (this, ev): any
        • Parameters

          Returns any

    Returns void

Methods

  • Registers an event handler of a specific event type on the EventTarget

    Type Parameters

    • K extends keyof WorkerEventMap

    Parameters

    • type: K
    • listener: ((this: Worker, ev: WorkerEventMap[K]) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof MessagePortEventMap

    Parameters

    • type: K
    • listener: ((this: MessagePort, ev: MessagePortEventMap[K]) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optionaloptions: boolean | AddEventListenerOptions

    Returns void

  • Disconnects the port, so it is no longer active.

    Returns void

  • Dispatches an event to this EventTarget.

    Parameters

    Returns boolean

  • Clones message and transmits it to worker's global environment. transfer can be passed as a list of objects that are to be transferred rather than cloned.

    Parameters

    • message: any
    • Optionaltransfer: StructuredSerializeOptions | Transferable[]

    Returns void

  • Removes an event listener from the EventTarget.

    Type Parameters

    • K extends keyof WorkerEventMap

    Parameters

    • type: K
    • listener: ((this: Worker, ev: WorkerEventMap[K]) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof MessagePortEventMap

    Parameters

    • type: K
    • listener: ((this: MessagePort, ev: MessagePortEventMap[K]) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optionaloptions: boolean | EventListenerOptions

    Returns void

  • Starts the sending of messages queued on the port (only needed when using EventTarget.addEventListener; it is implied when using MessagePort.onmessage.)

    Returns void

  • Immediately terminates the worker. This does not let worker finish its operations; it is halted at once. ServiceWorker instances do not support this method.

    Returns void