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.

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, ev) => any)
  • Is an EventListener that is called whenever an ErrorEvent of type error event occurs.

    Returns ((this, ev) => any)

      • (this, ev): any
      • Parameters

        Returns any

  • set onerror(value): void
  • Parameters

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

          Returns any

    Returns void

  • get onmessage(): ((this, ev) => any) | ((this, ev) => any)
  • An EventListener called when MessageEvent of type message is fired on the port—that is, when the port receives a message.

    Returns ((this, ev) => any) | ((this, ev) => any)

  • set onmessage(value): void
  • Parameters

    • value: ((this, ev) => any) | ((this, ev) => any)

    Returns void

  • get onmessageerror(): ((this, ev) => any) | ((this, ev) => any)
  • An EventListener called when a MessageEvent of type MessageError is fired—that is, when it receives a message that cannot be deserialized.

    Returns ((this, ev) => any) | ((this, ev) => any)

  • set onmessageerror(value): void
  • Parameters

    • value: ((this, ev) => any) | ((this, ev) => 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, ev) => any)
        • (this, ev): any
        • Parameters

          • this: Worker
          • ev: WorkerEventMap[K]

          Returns any

    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof MessagePortEventMap

    Parameters

    • type: K
    • listener: ((this, ev) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optional options: 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
    • Optional transfer: StructuredSerializeOptions | Transferable[]

    Returns void

  • Removes an event listener from the EventTarget.

    Type Parameters

    • K extends keyof WorkerEventMap

    Parameters

    • type: K
    • listener: ((this, ev) => any)
        • (this, ev): any
        • Parameters

          • this: Worker
          • ev: WorkerEventMap[K]

          Returns any

    • Optional options: boolean | EventListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Type Parameters

    • K extends keyof MessagePortEventMap

    Parameters

    • type: K
    • listener: ((this, ev) => any)
        • (this, ev): any
        • Parameters

          Returns any

    • Optional options: 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

Generated using TypeDoc