Skip to content
We're currently creating a lot of content. Sign up to get notified when it's ready.

Events

Qatium notifies plugins of events in the app through class methods that can be overriden as required. Depending on the data changing inside Qatium’s core, plugins can subscribe to specific events.

Plugin lifecycle

run()

Method signature

run(sdk: SDK): void

Required

Qatium calls a plugin’s run method whenever the plugin needs to be re-rendered. It will be called multiple times, with a variable frequency. This means:

  • Don’t use the run event for any timing code. It may be called multiple times per second, or not at all.
  • Be mindful of resources and try not to perform heavy calculations continuously.
  • Try to avoid side effects, as they might be called multiple times.

Use this method to perform any computations or rendering requiring querying the SDK.

It receives the SDK as an argument, containing all network and map actions and queries.

Example

class MyPlugin implements PluginI {
run(sdk: SDK) {
sdk.network.getAsset('MyAssetId')
}
}

onNetworkChanged()

Method signature

onNetworkChanged(sdk: SDK): void

Optional

Notified every time the network changes (due to scenarios initiated by the user, new SCADA readings being received, the user changing the current network date…)

It receives the SDK as an argument, containing all network and map actions and queries.

Example

class MyPlugin implements PluginI {
// Called when network has changed
onNetworkChanged(sdk: SDK) {
// Network API calls reflect new network state
const x = sdk.network.getPipes()
}
}

onZoomChanged()

Method signature

onZoomChanged(sdk: SDK): void

Optional

Notified every time the zoom changes due to user interaction.

It receives the SDK as an argument, containing all network and map actions and queries.

Example

class MyPlugin implements PluginI {
// Called when zoom has changed
onZoomChanged(sdk: SDK) {
// Map API calls reflect new state
const x = sdk.map.getCamera()
}
}

reset()

Method signature

reset(sdk: SDK): void

Optional

Notified every time the scenario gets deleted, causing all previous user made changes to be reset to the initial live model.

It receives the SDK as an argument, containing all network and map actions and queries.

Example

class MyPlugin implements PluginI {
// Called when the scenario is reset
reset(sdk: SDK) {
// ...
}
}

onMessage()

Method signature

onMessage(sdk: SDK, message: unknown): void

Optional

Notified every time the plugin receives a message from the plugin UI panel.

It receives the SDK as an argument and the message sent from the UI.

Example

class MyPlugin implements PluginI<MessageType> {
// Called when receiving a message from the UI
onMessage(sdk: SDK, message: MessageType) {
// ...
}
}