Building Apps with Jigx
...
Data Providers
REST

REST syncing & loading local Data

6min
key sync data from the cloud use a sync entities action to fetch data from the cloud and store it in the local sqlite database use the onload , onfocus , onrefresh , or any other event where actions are defined load data from sqlite to use on a jig use the data provider local in the datasource defined in the {{jig}} or a global datasource to execute an sqlite query save data to sqlite only to save data locally only and not sync to the cloud, use an execute entity action with the data provider local save data to sqlite and sync data to the cloud update the local sqlite and sync to the cloud in a single action to ensure high performing user experiences without lag use execute entity or execute entities actions with data provider rest specify the function call to make, the local entity/table to update, and the method to perform on the local table if the method is an update, delete, or save, specify the record's id save data to the cloud only use execute entity or execute entities actions with data provider rest set the method to the functioncall and specify the function to be called the local tables will not be updated; you must sync the data from the cloud before it is available to display on a {{jig}} using sync entities action use the sync entities action to sync data from the rest data store to the local sqlite data provider syncing data locally results in high performance with minimal lag and ensures all data is available in the app when the device is offline best practice is to configure a global action, the sync entities action, with the rest data provider, allowing reuse throughout the solution add the global sync action to the onfocus and onload events in the index jigx file ensures data is synced to the local data provider as soon as the app loads or is focused on the device add the global sync action to the onrefresh or onfocus events in a {{jig}} when data is changed, for example, on the list of customers, this ensures that when a new customer is created, the list is updated immediately when navigating to it or refreshing the list with a downward swipe using execute entity/entities action there are two options when using the execute entity and execute entities actions with remote data such as rest to update both the local sqlite table and the remote data store (rest and sql) to update the local table, specify create, update, or delete methods in the method property of the data provider, then specify the function to use in the function property, and under functionparameters specify the exact data to be updated, this updates the remote data store (rest or sql) after execution, a tempid is created, and then it is synced to the local table update local and rest providers to only update the rest data store to update the remote data store specify functioncall in the method property then specify the function to be called in the function property and under functionparameters specify the exact data to be updated note that the data will not be visible on the {{jig}} until a sync entities action is executed only update rest service consideration using the save method in execute entity/entities actions will perform an upsert in the local sqlite table dealing with offline remote data is fundamental to ensuring data synchronization and consistency between the mobile app and the remote data source, allowing users to continue using the app and performing actions without interruption offline remote data handling docid\ h36q0e3t93lcbn9wejmjp explains how to configure solutions to deal with data when the device is offline using local data provider in a {{jig}} 's datasources once the data has been synced using the sync entities action the data is available in the local data provider reference the local data provider in the {{jig}} 's datasource property to define the data required in the {{jig}} write a sqlite query to define the exact data required use intellisence and expressions to reference the specific datasource values to use in each component, such as data =@ctx datasources customers local data provider example see the rest docid\ lej3vf0o4nptfseucllaw code examples that show how to use remote data store with local data provider