Centralized loading manager that handles and tracks multiple loading operations.

This class manages the loading state across multiple file operations, providing progress tracking, error handling, and URL modification capabilities. A default global instance is created and used by loaders if not supplied manually.

Separate loading managers can be useful when you need independent loading progress tracking (e.g., separate progress bars for different types of resources).

import { AcCmLoadingManager } from './AcCmLoadingManager'

// Create a custom loading manager
const manager = new AcCmLoadingManager()

// Set up callbacks
manager.onStart = (url, loaded, total) => {
console.log(`Started loading: ${url} (${loaded}/${total})`)
}

manager.onProgress = (url, loaded, total) => {
console.log(`Progress: ${url} (${loaded}/${total})`)
}

manager.onLoad = () => {
console.log('All loading completed!')
}

manager.onError = (url) => {
console.error(`Failed to load: ${url}`)
}

Constructors

Properties

This function will be called when any item errors.

This function will be called when all loading is completed. By default this is undefined, unless passed in the constructor.

This function will be called when an item is complete.

This function will be called when loading starts.

Methods

  • Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. If no URL modifier is set, returns the original URL.

    Parameters

    • url: string

      The url to load

    Returns string

    Return resolved URL