Implementation of multiple markers by fetching data from local data base after sync

Implementation of multiple markers by fetching data from local data base after sync

  

Hi All, 

I was working on a mobile application and got stuck in a issue regarding the Implementation of multiple markers by fetching data from local data base after sync process is done. When I first implemented it by fetching the data from main data base using aggregate it went fine but now when I am implementing it by fetching data from local database after the implementation of 'OfflineSync' and 'TriggerSync' the map markers are not visible as data is not available. Although, the offline syncing shows 'Successful' message and data loaded when I inspect it. But, When I implemented 'Referesh Cordinate' aggregate in 'OnInitialise ' action  as shown in screenshot below and debug it then there is not data available from local database because of which map markers are not implementing.Please suggest any feasible solution to resolve this issue.


Thanks 

Hello Aditya,

You have to remember that mobile is highly assynchronous.
So, things for you to take into consideration:

1. Are your sync working properly?
2. When you execute this action, are you sure there is data in local storage already?
3. The "Refresh Coordinates" will be executed and the code will follow without waiting to it to finish. So, maybe in your for each the new data is not available yet. If this is the case, you can try a few things. Like moving your code that process data to the On Data Fetched action of the aggregate, for example.

Hope this helps.

Cheers.

Eduardo Jauch wrote:

Hello Aditya,

You have to remember that mobile is highly assynchronous.
So, things for you to take into consideration:

1. Are your sync working properly?
2. When you execute this action, are you sure there is data in local storage already?
3. The "Refresh Coordinates" will be executed and the code will follow without waiting to it to finish. So, maybe in your for each the new data is not available yet. If this is the case, you can try a few things. Like moving your code that process data to the On Data Fetched action of the aggregate, for example.

Hope this helps.

Cheers.

Hi Eduardo, 

Thanks for the suggestions you mentioned, can you pls elaborate your third point.The code which process the data is in "OnInitialise" action so I need to mention my this action in 'OnAfterFetch' of the aggregate or some where else.

Also, I have one more query that how to verify whether the data is actually stored in local storage or not.

- I have inspect the data of local storage by publishing the app and inspecting the data in chrome. There I am getting the data in local storage.

- Secondly, I had also debug the process by applying break point. But, in this case data is unavailable.


Is there any other way to verify that whether the data is stored in local data base or not? 


Hello Aditya

Every aggregate in mobile has a "On After Fetch" event, that is triggered when the data is fetched from the entity (local or server).

This event exists because the data fetching is assynchronous. This means that as soon as you start the fetch again (with the Data Refresh) in your client action, the execution will resume, while the data is still being fetched. 

And this means that is highly possible that you don't have any data yet when you start iterating the aggregate in your code. 

One possible solution is to put your processing code in a client action, and set it to be executed when the event triggers. This way you guarantee that the data is there for you to process.

Other possibilities include putting your interface (and code) in a block and put the block inside an IF with the IsDataFetched condition, so that when the data is fetched, the block is rendered again and you have the data to use.

If you didn't, you should do the online training, as all of this is seen there.

Cheers.

Eduardo Jauch wrote:

Hello Aditya

Every aggregate in mobile has a "On After Fetch" event, that is triggered when the data is fetched from the entity (local or server).

This event exists because the data fetching is assynchronous. This means that as soon as you start the fetch again (with the Data Refresh) in your client action, the execution will resume, while the data is still being fetched. 

And this means that is highly possible that you don't have any data yet when you start iterating the aggregate in your code. 

One possible solution is to put your processing code in a client action, and set it to be executed when the event triggers. This way you guarantee that the data is there for you to process.

Other possibilities include putting your interface (and code) in a block and put the block inside an IF with the IsDataFetched condition, so that when the data is fetched, the block is rendered again and you have the data to use.

If you didn't, you should do the online training, as all of this is seen there.

Cheers.

Thanks for reply...Eduardo


Also, I have one more query that how to verify whether the data is actually stored in local storage or not.

- I have inspect the data of local storage by publishing the app and inspecting the data in chrome. There I am getting the data in local storage.

- Secondly, I had also debug the process by applying break point. But, in this case data is unavailable.


Is there any other way to verify that whether the data is stored in local data base or not? 


Aditya Kumar Bhatt wrote:

Also, I have one more query that how to verify whether the data is actually stored in local storage or not.

- I have inspect the data of local storage by publishing the app and inspecting the data in chrome. There I am getting the data in local storage.

You can always create a page to see data. There is no other way beside those, I think, as you can't view data in the local storage.

- Secondly, I had also debug the process by applying break point. But, in this case data is unavailable.

As I explained above, the data fetching is assynchronous. This means that you execute the Data Refresh, and before the data is fetched, the execution resumes, so, when you start the iteration over the list of the aggregate, the data is (possibly) still not there.

That is the reason why you are not seeing data.

Another possibility is that your aggregate is not returning any data because it has joins or filters that will not fetch any data, but this only you can tell.

Cheers.