Variable Fetcher

Fetcher: {
    addEventListener: (<T>(type, listener) => void);
    arrayBuffer: ((url, options?) => Promise<ArrayBuffer>);
    blob: ((url, options?) => Promise<Blob>);
    fetch: ((url, options?) => Promise<Response>);
    getInfo: (() => {
        pending: number;
        running: number;
    });
    hasEventListener: (<T>(type, listener) => boolean);
    json: ((url, options?) => Promise<any>);
    removeEventListener: (<T>(type, listener) => void);
    text: ((url, options?) => Promise<string>);
    texture: ((url, options?) => Promise<Texture>);
    xml: ((url, options?) => Promise<Document>);
}

Exposes an API to perform HTTP requests. This should be used instead of the Fetch API in order to benefit from some error-checking, automatic configuration (from the HttpConfiguration module), etc.

Type declaration

  • addEventListener: (<T>(type, listener) => void)
      • <T>(type, listener): void
      • Adds a listener to an event type on fetch operations.

        Type Parameters

        • T extends "error"

        Parameters

        • type: T

          The type of event to listen to - only error is supported.

        • listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>

          The function that gets called when the event is fired.

        Returns void

  • arrayBuffer: ((url, options?) => Promise<ArrayBuffer>)
      • (url, options?): Promise<ArrayBuffer>
      • Wrapper over fetch to get some ArrayBuffer

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<ArrayBuffer>

        the promise containing the ArrayBuffer

        Fires

        error On Network/HTTP error

  • blob: ((url, options?) => Promise<Blob>)
      • (url, options?): Promise<Blob>
      • Wrapper over fetch, then returns the blob of the response.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Blob>

        The response blob.

        Fires

        error On Network/HTTP error

  • fetch: ((url, options?) => Promise<Response>)
      • (url, options?): Promise<Response>
      • Wrapper over fetch().

        Use this function instead of calling directly the Fetch API to benefit from automatic configuration from the HttpConfiguration module.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Response>

        The response object.

        Function

        Fires

        error On Network/HTTP error

  • getInfo: (() => {
        pending: number;
        running: number;
    })
      • (): {
            pending: number;
            running: number;
        }
      • Returns {
            pending: number;
            running: number;
        }

        • pending: number
        • running: number
  • hasEventListener: (<T>(type, listener) => boolean)
      • <T>(type, listener): boolean
      • Checks if listener is added to an event type.

        Type Parameters

        • T extends "error"

        Parameters

        • type: T

          The type of event to listen to - only error is supported.

        • listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>

          The function that gets called when the event is fired.

        Returns boolean

        true if the listener is added to this event type.

  • json: ((url, options?) => Promise<any>)
      • (url, options?): Promise<any>
      • Wrapper over fetch to get some JSON

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<any>

        the promise containing the JSON

        Fires

        error On Network/HTTP error

  • removeEventListener: (<T>(type, listener) => void)
      • <T>(type, listener): void
      • Removes a listener from an event type on fetch operations.

        Type Parameters

        • T extends "error"

        Parameters

        • type: T

          The type of the listener that gets removed.

        • listener: EventListener<FetcherEventMap[T], T, FetcherEventDispatcher>

          The listener function that gets removed.

        Returns void

  • text: ((url, options?) => Promise<string>)
      • (url, options?): Promise<string>
      • Wrapper over fetch to get some text

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<string>

        the promise containing the text

        Fires

        error On Network/HTTP error

  • texture: ((url, options?) => Promise<Texture>)
      • (url, options?): Promise<Texture>
      • Downloads a remote image and converts it into a texture.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Texture>

        the promise containing the texture

        Fires

        error On Network/HTTP error

  • xml: ((url, options?) => Promise<Document>)
      • (url, options?): Promise<Document>
      • Wrapper over fetch to get some XML.

        Parameters

        • url: string

          the URL to fetch

        • Optional options: RequestInit

          fetch options (passed directly to fetch())

        Returns Promise<Document>

        the promise containing the XML

        Fires

        error On Network/HTTP error

Generated using TypeDoc