Skip to main content

Lifecycle

Introduction

The SDK exposes various events and states in the lifecycle of the OpenSolar platform. These are key events which inform users when certain actions can be performed and when other actions should not be performed. Knowing when actions can be performed based on this lifecycle are detailed below.

The idle state

When the SDK is performing various processing and updates, it's important to avoid performing other operations in parallel to avoid ending up in an indetermine state. The key to understanding when the SDK is in a safe state is the idle state.

queueProcessed - idle

The queueProcessed signal is dispatched when various lifecycle state changes occur within the SDK. This returns a struct where the most relevant field is idle. When idle is true then this indicates that the system is not performing any other parallel operations.

Saving the project

It is safe to save the project when the system is in the idle state. In this case, calling project_form.save() can be called. This returns a promise which resolves once the project is saved.

project_form.saveState

Whether the project has been saved is recorded in project_form.saveState. A project is safe to save when it is not in the saving state (the project is in the process of being saved).

Design data

The design data of the project is updated when changes are made in the designer. These changes also trigger a request to perform calculations which happens asynchronously in the OpenSolar backend. While these calculations are being perform the idle state will be false until the calculations data is retrieved and updated in the design data.

For this reason, it's important to retrieve design data only when idle is true to ensure that the design data that is being accessed is not stale or is not pending an update. The design data can be retrieved with a call to project_form.getDesignData().