API Documentation

for 0.0.1
Show:

Cache Class

Cache gives the possibility to automatically avoid the reloading of the same ressource. It uses url to check if a given ressource has already been loaded or if it's currently loading. Cache exists only once as a static class of Loader and should never be created by user. Cache is enabled by default. To disable it, use Loader.Cache.enable(false) before you start using a Loader or a component that uses a Loader internally (like Button, RichText, etc.) It is used only in Loader static methods for now (to fix!).

Constructor

Methods

add

(
  • key
  • file
)

Add a file to the cache with the given key

Parameters:

  • key Object
  • file Object

addCallback

(
  • key
  • callback
)

Adds a callback coming from a Loader, with its associated key. We use a list of object as we must be able to register several callback that can have the same key.

Parameters:

  • key Object
  • callback Function

addKey

(
  • key
)

Add a key to the cache with no value, for further completion

Parameters:

  • key Object

addValue

(
  • key
  • file
)

Add a value to the cache to the given, already existing key

Parameters:

  • key Object
  • file Object

clear

()

Empty the file list

enable

(
  • enabled
)

Enable or disable cache

Parameters:

  • enabled Boolean

get

(
  • key
)
Object

Get the value of the given key

Parameters:

  • key Object

Returns:

Object:

the file in cache

getKey

(
  • key
)
Object

Get the key if it exists, even with no value

Parameters:

  • key Object

Returns:

Object:

the key or undefined

isCached

(
  • key
)
Boolean

Check if the file of the given key is aleady cached

Parameters:

  • key Object

Returns:

Boolean:

is cached or not

isLoading

(
  • key
)
Boolean

Check if the file of the given key is loading (only the key exists, not the value)

Parameters:

  • key Object

Returns:

Boolean:

is loading or not

remove

(
  • key
)

Remove the given key

Parameters:

  • key Object