Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Resource

Manages the state and loading of a resource and all child resources.

preferred

Hierarchy

  • Resource

Index

Type aliases

Static OnCompleteSignal

OnCompleteSignal: (resource: Resource) => void

Type declaration

Static OnErrorSignal

OnErrorSignal: (resource: Resource) => void

Type declaration

Static OnProgressSignal

OnProgressSignal: (resource: Resource, percent: number) => void

Type declaration

    • (resource: Resource, percent: number): void
    • Parameters

      Returns void

Static OnStartSignal

OnStartSignal: (resource: Resource) => void

Type declaration

Constructors

constructor

Properties

children

children: Resource[] = []

The child resources of this resource.

data

data: any = null

The data that was loaded by the resource. The type of this member is described by the type member.

error

error: string = ""

The error that occurred while loading (if any).

metadata

metadata: any

Extra info added by the user, usually for middleware.

name

name: string

The name of this resource.

onAfterMiddleware

onAfterMiddleware: Signal<OnCompleteSignal> = new Signal<Resource.OnCompleteSignal>()

Dispatched after this resource has had all the after middleware run on it.

onComplete

onComplete: Signal<OnCompleteSignal> = new Signal<Resource.OnCompleteSignal>()

Dispatched once this resource has loaded, if there was an error it will be in the error property.

onProgress

onProgress: Signal<OnProgressSignal> = new Signal<Resource.OnProgressSignal>()

Dispatched each time progress of this resource load updates. Not all resources types and loader systems can support this event so sometimes it may not be available. If the resource is being loaded on a modern browser, using XHR, and the remote server properly sets Content-Length headers, then this will be available.

onStart

onStart: Signal<OnStartSignal> = new Signal<Resource.OnStartSignal>()

Dispatched when the resource beings to load.

progressChunk

progressChunk: number = 0

The progress chunk owned by this resource.

type

type: ResourceType = ResourceType.Unknown

Describes the type of the data member for this resource.

see

ResourceType

Accessors

isComplete

  • get isComplete(): boolean

isLoading

  • get isLoading(): boolean

strategy

url

  • get url(): string

Methods

abort

  • abort(): void
  • Aborts the loading of the resource.

    Returns void

load

  • load(): void
  • Kicks off loading of this resource.

    Returns void

Static setDefaultLoadStrategy

Static setLoadStrategy

  • Sets the load strategy to be used for a specific extension.

    Parameters

    • extname: string

      The extension to set the type for, e.g. "png" or "fnt"

    • strategy: AbstractLoadStrategyCtor

      The load strategy to use for loading resources with that extension.

    Returns void

Generated using TypeDoc