Skip to content

Interface: SsRefCacheOptions<T> ​

Defined in: packages/react-native-spritestudio/src/core/SsRefCache.ts:25

A refcounted, URI-keyed cache for things that are expensive to build and safe to share.

Two of them exist: one for SsResource (parsing a .ssab and handing the bytes to the Brain) and one for decoded SkImage atlases. Without them, twenty <SpriteStudioSprite>s of one character parse the pack twenty times and decode its atlas twenty times, which is the cost that stops a list or a scene being practical.

Sharing an SsResource across players is not a liberty taken here — the C-API states it: "To save memory, a single Resource can be bound to multiple Contexts", and SsInternalPlayer already documents that it does not own the resource it is built against.

Why refcounts and not an LRU ​

Because SsRuntime.liveHandles has to keep meaning what it means. The leak check loads and disposes N times and asserts the counts come back exactly to their baseline, which only works while release is eager. An LRU would hold packs past their last user and read as a leak — so an entry is destroyed the moment its last lease is released, and anything that wants to outlive that says so through retain().

Type Parameters ​

T ​

T

Properties ​

destroy? ​

optional destroy?: (value) => void

Defined in: packages/react-native-spritestudio/src/core/SsRefCache.ts:27

Called when the last lease on a value is released.

Parameters ​

value ​

T

Returns ​

void