LayerCatalogue
The layers that exist, as definitions, and what is known about getting
them. It is a store that useSyncExternalStore can read: getState is
also the server snapshot, so a catalogue must answer it with no
subscription and without a browser.
This is an interface exported by @mapcairn/core, checked against version 0.2.0.
Signature
import type { LayerCatalogue } from "@mapcairn/core";
interface LayerCatalogue
Methods
getState
getState(): CatalogueState;
The catalogue's state now: loading, ready with its layers, or failed. It returns the same object until the state changes.
refresh
refresh(): Promise<void>;
Asks the catalogue to load again. Resolves when that attempt is over. The
state may change to loading before this returns or some time after, so a
caller must not read getState() straight after the call and expect it.
subscribe
subscribe(listener: () => void): () => void;
Calls listener after each change. Returns the function that stops it.
listener(() => void)
Remarks
getState returns the same object until the state changes, and a
subscriber is told once for each change. refresh never rejects: a
failure is the state. A static catalogue never changes, so it is ready
from the first read, never calls a subscriber and refreshes to nothing.
No method uses this, so a caller may pass getState and subscribe
on without the catalogue.