Binaries

backend.Binaries (Class)
Implements: spec.Binaries

Clay backend implementation for loading binary data files.

This class handles loading of raw binary data from various sources including:

  • Local filesystem (when available)
  • HTTP/HTTPS URLs
  • Application bundle resources

The implementation includes:

  • Asynchronous loading with callback support
  • Request deduplication (multiple requests for the same file share one load operation)
  • Hot reload support for development
  • Automatic path resolution relative to assets directory
See: spec.Binaries The interface this class implements, BinaryAsset For the high-level binary asset interface

Instance Members

clay
load(path: String, ?options: Null<LoadBinaryOptions>, _done: Function): Void

Loads binary data from the specified path.

The path can be:

  • Relative to the assets directory (e.g., "data/config.bin")
  • Absolute filesystem path (e.g., "/usr/local/data/config.bin")
  • HTTP/HTTPS URL (e.g., "https://example.com/data.bin")
Name Type Default Description
path String Path to the binary file to load
options Null<LoadBinaryOptions> (optional) Optional loading configuration (immediate callback execution)
_done Function Callback invoked with the loaded bytes data (null on error)

clay
supportsHotReloadPath(): Bool

Indicates whether this backend supports hot reloading of binary files. Clay backend always supports hot reload for development efficiency.

Returns Description
Bool true, indicating hot reload is supported

clay
new(): Void

Private Members

clay
loadingBinaryCallbacks: Map

Tracks pending load operations to prevent duplicate requests. Maps file paths to arrays of callbacks waiting for that file.