Skip to main content

ImageCache <T>

The class responsible for loading and caching images

Index

Constructors

constructor

  • new ImageCache<T>(name, browserCache, options): ImageCache<T>

Properties

_decode

_decode: (blob) => T | Promise<T>

Type declaration

    • (blob): T | Promise<T>
    • Parameters

      • blob: Blob

      Returns T | Promise<T>

_dispose

_dispose: (data) => void

Type declaration

    • (data): void
    • Parameters

      • data: T

      Returns void

browserCache

browserCache: BrowserCache

Persistent byte store, or null if the Cache API isn't usable.

cache

cache: Map<string, CachedImage<T>>

lastPurge

lastPurge: number

name

name: string

Methods

_imageStateDidChange

  • _imageStateDidChange(image): void
  • Private function called when an image state changes.


    Parameters

    Returns void

_refreshCharactersForImage

  • _refreshCharactersForImage(img): void
  • Given an image, refresh all characters that would be impacted by its load


    Parameters

    Returns void

clear

  • clear(): void
  • Clear all cached images


    Returns void

delete

  • delete(url): void
  • Remove a cached image by its URL.


    Parameters

    • url: string

      The URL of the image to delete

    Returns void

forEach

  • forEach(callback): void
  • Iterate over all cached images


    Parameters

    • callback: (img, key, map) => void

      The callback to call on each (URL, image) pair

      Returns void

    get

    • Get a cached image from the cache.


      Parameters

      • url: string

        The URL of the image to lookup

      Returns CachedImage<T>

      The cached image

    has

    • has(url): boolean
    • Check whether an image is in the cache


      Parameters

      • url: string

        The URL of the image to lookup

      Returns boolean

    purge

    • purge(force): void
    • Purge all images errored or not used in the last half-purge delay


      Parameters

      • force: boolean = false

      Returns void

    stats

    • stats(): void
    • Output some stats about the cache


      Returns void

    totalImages

    • totalImages(): number
    • Get the count of cached images.


      Returns number