Lets say I have 5 fetch from other sources on a web block.  One of them is on start and the other 4 are on demand.

For the one that is on start I have a "on after fetch" client action which, depending on the results from the first one will call the other 4 to refresh with data included from the first.  In that client action if I call a refresh for each of the 4 on demand fetch from other sources, do those 4 run synchronously - meaning it does the first THEN does the second THEN does the fourth?  Or does it start each of those 4 on fetch at more or less the same time and then they run asynchronously - meaning whichever of the 4 that finishes first will update its section of the screen?

I would assume the latter - as soon as it's refreshed it starts to run.

Kilian Hekhuis wrote:

I would assume the latter - as soon as it's refreshed it starts to run.

I would assume and hope for the latter as well but you know what they say about assuming.


Well, I'm almost positive, but I don't want to speak untruths :).

Hi Jason,

Everything you put on an action flow will run sequentially, even if it is an async call. Probably making the first call an OnInitialize screen event will work for you.

Cheers,
Tiago Simões

Tiago,

I was told to be very very careful about what I put, if anything, in on initialize etc.  I do need to do a server call for this to get their permissions before I initialize the other calls.  Would you do this in the on initialize or might it be better to have a block which does the permission check and then after that fetch is done if permissions are ok it will then load the second block (with permission data passed in) and then call the fetch other data source on "at start"?

Hi Jason,

Yes, making the other data calls on an internal block it's another smart solution. You would need just a block, as you could do the initial call in the screen itself.

The OnInitialize call, if fast, is not a big issue, users will get a flicker as they change screens, but that is very common in most of the web (on mobile apps not so much). You need to check the experience and then balance experience with maintainability, that really depends on your project.

Cheers,
Tiago Simões 

Tiago Simões wrote:

Hi Jason,

Yes, making the other data calls on an internal block it's another smart solution. 

The OnInitialize call, if fast, is not a big issue, users will get a flicker as they change screens, but that is very common in most of the web. You need to check the experience and then balance experience with maintainability, that really depends on your project.

Cheers,
Tiago Simões 

Tiago,

Ok, I will go the nested block method then.  Although this does bring up a question.  If you use the "on parameters changed" action and you have 5 fetch from other data sources used on your page - if you use that feature (and the studio gives you warnings if you don't) then are those fetch from other data sources then called synchronously vs asynch?  In that case wouldn't it be faster to reload if I just refresh the block a level above instead of doing the on parameters changed?


Hi Jason,

Yes, you are right, they are also called synchronously. Consider putting the block inside an if and only render it when the outer screen call returns.

In any of these consider testing with real data, in several cases we often are optimizing prematurely as most data calls are quick (specially compared with traditional web, where the rendering was done on the server).

Cheers,
Tiago Simões

Tiago,

Ok - that is good to know and changes the way we will architect.  With the current Covid stuff going on I am making some report screens needed right away that are very data and time intensive on loading/processing data so anything I can do should be immediately visible as far as call times as I am developing on our prod server with live data.