TileStoretype
A tile store: tiles by source and key, under one byte budget.
Import it
import type { TileStore } from "@johnmorrisdotca/hoshi-stars/door";
Definition
interface TileStore<Tile> {
want(source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile>;
get(sourceId: string, key: string): Tile | undefined;
drop(sourceId: string): void;
stats(): TileStats;
idle(): Promise<void>;
}
Members
| Name | Type | Description |
|---|---|---|
want | (source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile> | Tells the store which tiles |
get | (sourceId: string, key: string): Tile | undefined | One held tile, or |
drop | (sourceId: string): void | Forgets a source: aborts its loads, frees its tiles. The source is switched off. |
stats | (): TileStats | |
idle | (): Promise<void> | Resolves when no load is running or waiting. |
Examples
import type { TileStore } from "./data-door.ts";
const held = (store: TileStore<Uint8Array>): number => store.stats().held;