About mobile screen lifecycle event

Referring to the documentation, https://success.outsystems.com/Documentation/11/Developing_an_Application/Implement_Application_Logic/Screen_and_Block_Lifecycle_Events

In the project, i cannot use local storage and have to make all data fetches through API calls.

I have 3 drop down controls: Countries > States >> Races where each selection affects the output data bind of the next list.

On top of that, i have to hide and show certain sections based the Previous and Next buttons pressed. Section 1 is Demographic (Countries > States >> Races). 

Section 2 is Profile where the customers have to select Gender > Age Range. 

Section 3 is Career where the customers have to select Industries > Salary Range.

This is a one-page app where everything happens in one screen. Additional screen are not allowed due to user requirement.

1) In web, i can call IsLoadingScreen() to check if the page is called the first time, does it work the same way in mobile so that certain API calls are made only once (such as Countries).

2) The article in the link above stated that Render is called whenever a data is being fetched. So it is right for me to make an API call at OnInitialize to fetch countries? If there is a failure to fetch countries, i will have to redirect the user to login page.

3) Since certain selection affects subsequent drop down list, do i put the RefreshData widget in the OnChange or in the OnRender event handlers?

4) Does anyone know if there are more examples regarding the OnInitialize, OnReady, OnRender, OnDestroy? I need some more references to know which type of flow i can add on each of the 4 handlers to prevent performance issue.

Hi,

I believe Blocks and Events will be your best friend here. Best make yourself comfortable with them. Consider the lifecycle events for each block you use (according to business concept, is my suggestion). So in your OPA you will have many blocks, that are displaying or not according to what is asked of you, controllable with local variables, for example. Changing the inputs of these blocks, will trigger their OnParametersChanged event, like described in that link you shared. You could make use of this to execute your data actions and fetch the needed data only once. Upon Changing anything inside a block, use Events to let that information be part of the screen.

You can read more on Blocks behaviour here.

Let me know if this helps,

Sam

1) In web, i can call IsLoadingScreen() to check if the page is called the first time, does it work the same way in mobile so that certain API calls are made only once (such as Countries).

This would be OnInitialize, although fetching of data should not be performed here. Instead, use the fetch actions, i,e, "Fetch Data from Database", "Fetch Data from Local Storage", or "Fetch Data from Other Sources", for actions pertaining to data gathering. You can use screen variables, input or local, as parameters inside these fetch actions. You need to perform these fetches separately, so you can isolate when a certain set of data needs to be refreshed.


2) The article in the link above stated that Render is called whenever a data is being fetched. So it is right for me to make an API call at OnInitialize to fetch countries? If there is a failure to fetch countries, i will have to redirect the user to login page.

Use "Fetch Data from Other Sources" for API calls. There is an OnAfterFetch event where you can make actions after fetch, and make your desired check action.


3) Since certain selection affects subsequent drop down list, do i put the RefreshData widget in the OnChange or in the OnRender event handlers?

Do it in the OnChange event of the corresponding dropdown widget. You only need to refresh the expected data if you separated the fetching.


4) Does anyone know if there are more examples regarding the OnInitialize, OnReady, OnRender, OnDestroy? I need some more references to know which type of flow i can add on each of the 4 handlers to prevent performance issue.

For me I just refer to the comments auto-generated by the platform.


Hope this helps!

- Emman