Preload dashboard data

This feature makes the dashboard data available for the user at load time.

Overview

This consists of a toggle button that, when enabled, changes the widget logic so dashboard data is preloaded and available as the dashboard loads.

Before this feature was added, users could only retrieve data from the Ubidots class by listening for an event and reading the required variable inside the callback.

For example, if you wanted to get your Ubidots token and the ID of the currently selected device, you could do it as follows:

However, this requires advanced JavaScript knowledge and familiarity with custom Ubidots events.

With Preload dashboard data enabled, you can access the same values directly:

There is no need to instantiate the Ubidots class, since an instance already exists.

Class properties when Preload dashboard data is disabled

When Preload dashboard data is disabled, some class properties may appear as undefined. This happens because the class instance has not yet received their values. Consider the following code snippet:

Although ubidots.token is valid syntax and the Ubidots class includes that property, the first console.log prints undefined. The other two print the token correctly because the property is only available after the event sets its value.

Last updated

Was this helpful?