FakeLayerCatalogue
A LayerCatalogue a test scripts directly.
This is a class exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { FakeLayerCatalogue } from "@mapcairn/core";
class FakeLayerCatalogue implements LayerCatalogue
Description
How to script it: pass the layers it should hold (none by default, which
matches the host in this release) and it is ready with them. Call
setLayers to replace them and setState to put it in any state, such as
loading or failed; each tells the subscribers once. refresh only
counts the calls in refreshes and changes nothing, so a test decides what
a refresh does by calling setState itself.
Constructors
(constructor)
constructor(layers?: readonly LayerDefinition[]);
Constructs a new instance of the FakeLayerCatalogue class
layers?(readonly LayerDefinition[])
Properties
getState
readonly getState: () => CatalogueState;
The state now, which setLayers and setState change. The same object is returned until then.
refresh
readonly refresh: () => Promise<void>;
Counts the call in refreshes and changes nothing; a test decides what a refresh does by calling setState.
refreshes
refreshes: number;
How many times refresh has been called.
subscribe
readonly subscribe: (listener: () => void) => (() => void);
Calls the listener after each change. Returns the function that unsubscribes. An arrow property, so it works unbound.
Methods
setLayers
setLayers(layers: readonly LayerDefinition[]): void;
Replaces the layers, ready with none skipped, and tells the subscribers.
layers(readonly LayerDefinition[])
setState
setState(state: CatalogueState): void;
Puts the catalogue in state as it is, and tells the subscribers.
state(CatalogueState)