Class ResourceElement

Handles loading a resource DOM element and listening for when it's finished or failed to load.

This is designed to handle race conditions whereby a resource added but not yet fully loaded. Event handlers can be registered even after a resource has loaded with event handlers being fired.

Hierarchy

  • ResourceElement

Constructors

Properties

#errorListeners: Set<Callback> = ...
#loadListeners: Set<Callback> = ...
#resource: HTMLLinkElement | HTMLScriptElement
failed: boolean = false
ready: boolean = false

Methods

  • Add event listeners for when a resource has loaded or failed to load.

    Parameters

    • onLoad: Callback

      A callback for when the resource has loaded successfully.

    • onError: Callback

      A callback for when the resource has failed to load.

    Returns void

  • A callback made by the resource DOM element for when the resource fails to load.

    Returns void

  • A callback made by the resource DOM element for when the resource has loaded successfully.

    Returns void

  • Removes load and error event listeners.

    Parameters

    • onLoad: Callback

      A callback for when the resource has loaded successfully.

    • onError: Callback

      A callback for when the resource has failed to load.

    Returns void

Generated using TypeDoc