createTileStorefunction
A tile store for a view: loads the tiles of every source by key and keeps them under one budget of bytes (default 48 MB, all sources together).
- At most
maxInFlightloads (6) run at once for a source, and a load starts only because the keys changed: at rest the store sends nothing, and a tile that failed waits for the next change. - The least recently used tile goes first when room is needed, and never a tile the view needs now. If a new tile does not fit even so, it is refused and counted: the held bytes never pass the budget (nor the count, if
maxTilesis set). - A tile that throws, comes back empty or reports a size that is not a finite number is counted in
failedand never held, so it is never drawn. drop(sourceId)aborts the source's loads and frees its tiles.
Import it
import { createTileStore } from "@johnmorrisdotca/chikyu-earth/door";
Definition
function createTileStore<Tile>(options?: TileStoreOptions): TileStore<Tile>
Parameters
| Name | Type | Description |
|---|---|---|
options (optional) | TileStoreOptions | Budget, loads in flight, and a callback for a redraw. |
Returns
TileStore<Tile>
The store.
Examples
import { createTileStore } from "./data-door.ts";
const store = createTileStore<Tile>({ onChange: draw });
const held = store.want(source, source.need(place, detail)); // draws what is held now; the rest arrives through onChange
store.drop(source.info.id); // the layer is switched off