When Component`s constructor is being executed?

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

We have a requirement of switching theme based on pre/post app init service callback response. But before waiting for the response, all the component constructors are executed.

Note :

  1. First form, which is shows as startup page don`t have any components. I wonder, why components` constructors are triggered, though its not part of first form.
  2. Its a Freeform project.

Thanks

Hi,

In the case of a free form project, the widgets within a form are initialized on first access of the form in code.

e.g. If there is a form with name "Form1" in the application and somewhere in the code if "Form1" is accessed, widgets within "Form1" will be initialized.

If any such form consists of a component instance, then the constructor of its corresponding component source is invoked.

Ensure that there are no references to forms containing component instances within the code that is executed during application startup.

Regards

Even my understading is also same. All the widgets, which are part of a form, will be initialized once used.

But, am seeing All the Component`s constructs are invoked, while preapp init itself regardless of its been used or not.

is it an issue ?

Looks like an issue. All forms are being initialized on application launch itself. Please destroy the form so that you can work with its constituent component's constructor post your service call.

And looks like this is happening only on preview, can you confirm if you are using preview or the full build?

We are doing complete build for desktop web.