Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WorkerServiceProxy

A worker service proxy will forward function calls to an observable. This observable can be a remote process or worker. It is mainly used to proxy function calls from a worker thread to the main thread.

Hierarchy

  • ServiceProxy<Service>
    • WorkerServiceProxy

Index

Constructors

constructor

Properties

logger

logger: (level: string, log: any) => void = ...

Type declaration

    • (level: string, log: any): void
    • Parameters

      • level: string
      • log: any

      Returns void

name

name: string

Service name

Protected options

options: WorkerProxyOptions

Readonly Static captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Readonly Static errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): WorkerServiceProxy
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

createHandler

  • createHandler(target: Service, p: PropertyKey): (...args: any[]) => any
  • Create handler function for a specific property key

    Parameters

    • target: Service

      Target service

    • p: PropertyKey

      Property

    Returns (...args: any[]) => any

    Handler function

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

emit

  • emit(name: string | symbol, ...args: any[]): boolean
  • emit(name: "ready"): boolean
  • emit(name: "destroy"): boolean
  • Parameters

    • name: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Service ready

    Parameters

    • name: "ready"

      ready

    Returns boolean

  • Destroy the service

    Parameters

    • name: "destroy"

      destroy

    Returns boolean

emitAsync

  • emitAsync(type: string | symbol, ...args: any[]): Promise<boolean>

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

Optional get

  • get(target: Service, p: PropertyKey): any

getMaxListeners

  • getMaxListeners(): number
  • Returns number

isReady

  • isReady(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

on

  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

once

  • Parameters

    • name: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

  • Event called when service is destroyed

    Parameters

    • name: "destroy"

      destroy

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns WorkerServiceProxy

  • Event called when service is build

    Parameters

    • name: "build"

      build

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns WorkerServiceProxy

  • Event called when service is ready

    Parameters

    • name: "ready"

      ready

    • listener: () => void | Promise<void>

      Event callback

        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns WorkerServiceProxy

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): WorkerServiceProxy
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): WorkerServiceProxy
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns WorkerServiceProxy

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): WorkerServiceProxy
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns WorkerServiceProxy

Optional set

  • set(target: Service, p: PropertyKey, value: any): boolean

setMaxListeners

  • Parameters

    • n: number

    Returns WorkerServiceProxy

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string

    Returns Promise<any[]>