Let's just say i want to synchronize several records when i logged in to the mobile app for the better performance. The records that being synchronize is the 30 first records, and it's going to be appear in the home screen as a list. And then when on the scroll ends, i need it to be synchronized again for 10 records each scroll.


The question, how to implement these flow as i mentioned above? As far as i remember, the offlinesync action is for synchronize all of the entity records, not partial.

Hi Aditya,

You can implement any sync logic you want. For sure there is no obligation to synchronize all of the entity records.

Regards,

Daniel

Hi Aditya,

You really don't want to sync when the scroll ends, because this means the user has to wait for a considerable time, which is very user unfriendly. The whole idea of syncing is that you have all the relevant data locally, so the user does not have to wait.

Kilian Hekhuis wrote:

Hi Aditya,

You really don't want to sync when the scroll ends, because this means the user has to wait for a considerable time, which is very user unfriendly. The whole idea of syncing is that you have all the relevant data locally, so the user does not have to wait.

alright, so with your statement I assumed for a list records that always change dynamically it is recommended to not be synced and stored to the local storage? then the source of the list would be better from the server entity?


beside, if i synchronized the whole records in the first time opening the app, wouldn't that slowed the performance?

Hi Aditya,

  1. For a mobile app, it is recommended to always sync the data if possible, as that will result in a better user experience. Waiting for the server leads to slow-downs.
  2. Synchronizing can be done in the background, so there's no need for the app to slow down.


Kilian Hekhuis wrote:

Hi Aditya,

  1. For a mobile app, it is recommended to always sync the data if possible, as that will result in a better user experience. Waiting for the server leads to slow-downs.
  2. Synchronizing can be done in the background, so there's no need for the app to slow down.


okay, but here's my case, i have a list widget from an entity as a source. and the records from that entity needed to be refreshed periodically, this means i have to set the list to be updated to local entity.

anyway how to synchronizing in the background? where do i put the logic and what triggers it?

Solution

Hi Aditya,

The Sync Framework in OutSystems always runs in the background (I believe there's references to that in the online training, likely here and here).

Sync happens at very specific moments: on user login, when the app resumes after the user switched to another app on the device and when the device comes back online. You can also explicitly trigger the sync (review the Local Storage lesson and exercise), but you don't have that much control over when it starts or how long it takes. You can however be notified when the sync finishes.

Since syncing always happens in the background, it has no direct impact on the user's interaction with the app itself (only with the new/fresh data that may be presented to the user).

Using the JavaScript equivalent to timers (check the setTimeout()/clearTimeOut() or setInterval()/clearInterval() methods, depending on what your goal is), you can have your app regularly trigger the sync but, as a general rule of thumb... you probably don't want to.  

Also, you can decide to sync partially your data, by using the SyncUnit input parameter to "identify" a unit of synchronisation. How you use SyncUnit input parameter is up to you, but it will be passed around by the framework so every sync piece of logic you implement can be aware of it, and can use that info to decide what data to sync.

Hope this helps!

Solution