Mobile: waiting on more than one local data source

Mobile: waiting on more than one local data source

  

I have a mobile app that has a few screens that are run in succession. The last screen checks whether the data in the previous screens has been entered correctly. The problem I'm facing is that some checks need more than one data source for verification. If I use an OnAfterFetch, I'm only assured that that particular source has been fetched, but not the other one. How can I achieve this?

Might be me, but I don't follow your use case. Not a specialist yet in the mobile development.

I suppose the data of all the screens is stored in the local storage. So I would expect to be able to read that data and verify that it's correct, no?

Hi Kurt,

With mobile apps, there's no Preperation that's used for retrieving the data you need. Instead, you specify the query's as part of the screen itself, and the data is fetched asynchronously. This is important for usability and UI responsiveness, but it poses some problems if you need to perform checks based on two or more data queries, because you can't trivially determine whether all data has been fetched.

The only "solution" as I see it (which is more of a work-around) is to specify an OnAfterFetch for each data source, set a local variable indicating "fetching finished" and check whether all such flags are set, in which case you can perform the checks.

Hi Kilian,

Have you tried using a Data Action to enclose the Aggregates and use its On After Fetch? Depending on the concrete use case, you might also do with checking the IsDataFetched runtime properties of both Aggregates.

Let me know if neither of these works for your scenario.

Regards,

Paulo

Hi Paulo,

I didn't think of the IsDataFetched property, thanks for the reminder. But otherwise I think I've described what I think you are suggesting above, viz. create an On After Fetch for each Aggregate, and check in each of the actions whether everything has been fetched. If that's what you had in mind, then we agree :). However, I would've liked a better way, but it seems there's none.

Hi Kilian,

The first option I suggested was enclosing all relevant Aggregates in a Data Action, and define a single On After Fetch (for the Data Action) with the logic. The downside is that those Aggregates are not fetched independently of each other, but depending on how they are used in the screen that might not be an issue for your scenario.

Cheers,

Paulo

Hi Paulo,

I see, I didn't read too careful what you wrote, appologies. However, in this case it's local storage data, if I understand correctly a Data Action runs on the server, fetching server data?

Solution

I was assuming you were talking about server Aggregates, yes. For Local Storage, I think your only options are the IsDataFetched runtime properties or the logic you described using On After Fetches.

Solution