Class NetworkMetricsControllerImpl

An object that may dispatch events and have handlers for those events. Similar to the DOM's EventTarget, this is a basic event system based on event naming.

Some of the advantages of EventHost over EventTarget:

  • Not all supported platforms support EventTarget construction or extension.
  • EventTarget is designed for the DOM, with bubble and capture phases not necessary in Vinyl.
  • Event types are strict.
  • Events can be plain objects, no need to extend CustomEvent.
  • Easier unsubscription and disposal; reduces the risk of memory leaks.

EventHost supports concurrent modification, that is, handlers may be added or removed during the execution of another handler.

Hierarchy (view full)

Implements

Constructors

Properties

logPrefix: string = ...

A string prefix for all log statements made by this target.

Accessors

  • get [toStringTag](): string
  • Returns string

Methods

  • Adds information about a completed settled request. Note: This does not update estimated bandwidth.

    Parameters

    Returns void

  • Dispatches an event.

    Type Parameters

    • K extends "metricsChange"

    Parameters

    • type: K

      The key of the event within EventMap

    • event: NetworkMetricsEventMap[K]

      If the passed event is read-only, then it may be re-used/cached. Otherwise, it should be a new event object every dispatch. If no target property is set on the event, the target will be set to this host.

    Returns void

  • Returns void

  • Adds an event handler for the given typed event.

    Type Parameters

    • K extends "metricsChange"

    Parameters

    • type: K

      The key representing the event type to listen for.

    • handler: EventHandler<NetworkMetricsEventMap[K]>

      A callback to invoke when the event with the given type is dispatched.

    • Optionaloptions: SignalOptions

      Options for changing listening behavior.

    Returns Unsubscribe

    Returns a method, when invoked, removes the handler.