# MapStore

Something a page can read and listen to, in the shape of `LayerCatalogue`:
`getState` returns the same object until the state changes, and `subscribe`
calls the listener after each change, never from inside `subscribe`, and
returns the function that stops it. No method uses `this`, so both can be
passed on as they are, to React's `useSyncExternalStore` for one. In
releases after `0.2.0`, not in `0.2.0` or any earlier release.

This is an interface exported by `@mapcairn/map`, checked against version 0.2.0.

## Signature

```ts
import type { MapStore } from "@mapcairn/map";
 
interface MapStore<State>
```

## Type parameters

- `State`

## Methods

### getState

```ts
getState(): State;
```

The state now.

### subscribe

```ts
subscribe(listener: () => void): () => void;
```

Calls `listener` after each change. Returns the function that stops it.

- `listener` (`() => void`)

Source: [packages/map/src/element/stores.ts:11](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/element/stores.ts#L11)
