Class: CacheRecord

OpenSeadragon.CacheRecord

Cached Data Record, the cache object. Keeps only latest object type required. This class acts like the Maybe type: - it has 'loaded' flag indicating whether the tile data is ready - it has 'data' property that has value if loaded=true Furthermore, it has a 'getData' function that returns a promise resolving with the value on the desired type passed to the function.

Constructor

new CacheRecord()

Source:

Members

data

Access the cache record data directly. Preferred way of data access. Might be undefined if this.loaded = false. You can access the data in synchronous way, but the data might not be available. If you want to access the data indirectly (await), use this.transformTo or this.getDataAs
Source:

type

Read the cache type. The type can dynamically change, but should be consistent at one point in the time. For available types see the OpenSeadragon.Converter, or the tutorials.
Source:

Methods

addTile(tile, data, type)

Add tile dependency on this record
Parameters:
Name Type Description
tile
data can be null|undefined => optimization, will skip data initialization and just adds tile reference
type
Source:

await() → {OpenSeadragon.Promise.<?>}

Await ongoing process so that we get cache ready on callback.
Source:
Returns:
Type
OpenSeadragon.Promise.<?>

destroy()

Free all the data and call data destructors if defined.
Source:

getDataAs(typeopt, copyopt) → {OpenSeadragon.Promise.<?>}

Access the cache record data indirectly. Preferred way of data access. Asynchronous.
Parameters:
Name Type Attributes Default Description
type string <optional>
copy boolean <optional>
true if false and same type is retrieved as the cache type, copy is not performed: note that this is potentially dangerous as it might introduce race conditions (you get a cache data direct reference you modify).
Source:
Returns:
desired data type in promise, undefined if the cache was destroyed
Type
OpenSeadragon.Promise.<?>

getTileCount() → {number}

Get the amount of tiles sharing this record.
Source:
Returns:
Type
number

isUsableForDrawer(drawer) → {boolean}

Check whether the cache is usable for the given drawer. The cache is considered usable if it is in a format supported by the drawer and, if the drawer uses internal cache, the internal cache was created (it might not be loaded yet though).
Parameters:
Name Type Description
drawer OpenSeadragon.DrawerBase
Source:
Returns:
Type
boolean

removeTile(tile) → {Boolean}

Remove tile dependency on this record.
Parameters:
Name Type Description
tile
Source:
Returns:
true if record removed
Type
Boolean

revive()

Set initial state, prepare for usage. Must not be called on active cache, e.g. first call destroy().
Source:

setDataAs(data, type) → {OpenSeadragon.Promise.<?>}

Set the cache data. Asynchronous.
Parameters:
Name Type Description
data any
type string
Source:
Returns:
the old cache data that has been overwritten
Type
OpenSeadragon.Promise.<?>

toString() → {string}

Get cache description. Used for system messages and errors.
Source:
Returns:
Type
string

transformTo(type) → {OpenSeadragon.Promise.<?>}

Transform cache to desired type and get the data after conversion. Does nothing if the type equals to the current type. Asynchronous. Transformation is LAZY, meaning conversions are performed only to match the last conversion request target type.
Parameters:
Name Type Description
type string | Array.<string> if array provided, the system will try to optimize for the best type to convert to.
Source:
Returns:
Type
OpenSeadragon.Promise.<?>