Events

The SDK employs an event emitter to notify external interfaces of changes within the library. This decouples the SDK from any specific UI or state management library, allowing for greater flexibility and reusability.

Listening to Events

To react to changes emitted by the SDK, you can listen to events using the following example:

engine.events.on("layer:added", (payload) => {
  drawNewLayerInUI(payload.layerId);
});

This code sets up an event listener for the layer:added event, which is triggered whenever a new layer is added. The drawNewLayerInUI is an imaginary function responsible for representing the layer into the UI.

The list of all the supported events can be found in the API Reference.