Listening events
Access dashboard settings via event handlers
Overview
A event is an action that takes place in a dashboard at load time or triggered by other specific actions.
Registering for an event
You can register an event handler for any of the events above in the following way:
or
The event handler function's arguments must match the event signature.
Available events
You can register event handlers for the following events:
Event | Triggered |
---|---|
| At dashboard load time, when the token information is being retrieved. |
| Whenever the dashboard's date range is changed via GUI or a calling to the corresponding method. |
| Whenever the dashboard's real time setting is changed via GUI or a calling to the corresponding method |
| When a user clicks the refresh button in the dashboard. |
| When the selected device in a dynamic dashboard is changed via GUI or a calling to the corresponding method. |
| At dashboard load time, when the dashboard information is being retrieved. |
| After changing the dashboard's filters configuration |
| At dashboard load time, after all other events have been triggered. |
receivedToken
receivedToken
Handler argument: token
: string
=>The account's default token.
Signature
selectedDashboardDateRange
selectedDashboardDateRange
Handler argument: timeframe
: Object
=>The dashboard's timeframe.
Signature
isRealTimeActive
isRealTimeActive
Handler argument: rt
: Bool
=>The dashboard's real time update setting.
Signature
dashboardRefreshed
dashboardRefreshed
Handler argument: None
Signature
selectedDevices
selectedDevices
Handler argument: deviceIds
: [string]
=> String array of the id's of the currently selected devices in a dynamic dashboard
Signature
selectedDeviceObjects
selectedDeviceObjects
Handler argument: deviceObjects
: [Objects]
=> Object array of the device objects of the currently selected devices in a dynamic dashboard
Signature
selectedDashboardObject
selectedDashboardObject
Handler argument: dashboardObject
: Object
=> dashboard object
Signature
selectedFilters
selectedFilters
Handler argument: dashboardFilters
: [[Object]]
=> Array of arrays containing the filter objects. Each nested array corresponds to a filter configured on the dashboard.
Signature
ready
ready
Handler argument: None
Signature
Events relation with the class' properties
Each of the events mentioned above is related to a property within the Ubidots class that can be used to retrieve exactly the same data as an alternative to setting an event handler and waiting for the event:
Ubidots class property | Associated event |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For example, you can configure an event to retrieve data from the selected device each time the dashboard's device picker is used, as shown below:
This way, everytime that the device picker is used, the logic within the event will be executed. As an alternative to this, if you don't require to perform an action upon the event triggering but only require the data of the currently selected device, you can just access the property related to the event as:
Last updated