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

init()

Method signature

init(): void

Optional

Qatium calls a plugin’s init method only once. You can think about it as the entry point for your plugin.

Example

import { Bounds } from '@qatium/sdk';
class MyPlugin implements Plugin {
private bounds: Bounds;
init() {
this.bounds = sdk.network.getBounds();
}
}

run()

Method signature

run(): void

Optional

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 using the SDK.

Example

class MyPlugin implements Plugin {
run() {
sdk.network.getAsset('MyAssetId')
}
}

onNetworkChanged()

Method signature

onNetworkChanged(): 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…)

Example

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

onZoomChanged()

Method signature

onZoomChanged(): void

Optional

Notified every time the zoom changes due to user interaction.

Example

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

reset()

Method signature

reset(): void

Optional

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

Example

class MyPlugin implements Plugin {
// Called when the scenario is reset
reset() {
// ...
}
}

cleanUp()

Method signature

cleanUp(): void

Optional

Notified when the plugin is gettign cleaned up. This happens when the user is exiting the network view or disabling the plugin.

You can use this method, for example, to abort in progress operations.

Example

class MyPlugin implements Plugin {
// Called when the network is cleanUp
cleanUp() {
// ...
}
}

onMessage()

Method signature

onMessage(message: any): void

Optional

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

It receives the message sent from the UI.

Example

class MyPlugin implements Plugin {
// Called when receiving a message from the UI
onMessage(message: MessageType) {
// ...
}
}

onElementSelected()

Method signature

onElementSelected(element?: ElementIdentifier): void;

Optional

Notified every time the user selects an Asset in the map.

Example

class MyPlugin implements Plugin {
onElementSelected(element?: ElementIdentifier) {
sdk.ui.sendMessage<MessageToUI>({
event: "selected-element-changed",
id: element?.id
});
}
}