Skip to content

Function: subscribe()

ts
function subscribe(handler): Unsubscribe;

Subscribe to Mapsted Maps JavaScript API state changes. Callable pre-init — subscribers receive LOADING → READY transitions during init. This is documented behavior.

Parameters

ParameterTypeDescription
handler(state) => voidCallback invoked on every state change. Receives the full MapState snapshot. Type: (state: MapState) => void.

Returns

Unsubscribe

An Unsubscribe function — call it to detach the handler.

Throws

MAPSTED-1091 when handler is not a function.