Data synchronization JavaScript API
When you design an application that users can access with an offline-enabled mobile app on a mobile device, you can configure data synchronization frequency, data synchronization throttling, and the behavior of the synchronization indicator, by calling several JavaScript methods.
window.datasyncStart()
- Initiates data synchronization when the user interacts with the control that
you configure to invoke the
Run script
action. When the datasyncStart method is called, the synchronization indicator immediately presents the Syncing/Synced label. pega.offline.DataSync.start
- Initiates data synchronization when called from the custom JavaScript code that defines the logic of your application. When the start method is called, the synchronization indicator does not present the Syncing/Synced label, unless there has been a noticeable delay.
pega.offline.DataSync.setIntervalBetweenSynchronizationsWhenServerAccessible
- Sets the interval (in milliseconds) between subsequent synchronization sessions when the server is available. The default value is 300000 ms (5 minutes). The value must be greater than 0.
pega.offline.DataSync.setIntervalBetweenSynchronizationsWhenServerInaccessible
- Sets the interval (in milliseconds) between subsequent synchronization sessions when the server is not available. The default value is 60000 ms (1 minute). The value must be greater than 0.
pega.offline.DataSync.setQueueMaxSize
- Sets the number of actions in the action queue that must be reached before synchronization is triggered. The default value is 1, which means that the app sends actions immediately to the server after they are added to the action queue.
pega.offline.DataSync.setQueueFlushInterval
- Sets the amount of time (in milliseconds) that must pass from the moment an action is queued in the client store before synchronization is triggered. The default value is 0, which means synchronization happens immediately.
pega.offline.DataSync.enableFlushOnLastStep
- Enables or disables synchronization triggering after the user processes the last step in an assignment. The default value is false.
pega.offline.DataSync.isFlushOnLastStepEnabled
- Specifies whether synchronization triggering is enabled after the user processes the last step in an assignment.
pega.offline.DataSync.setMaxNumberOfActionsPerRequest
- Sets the maximum number of actions that can be sent with a single request. The default value is 60, which means that the app sends up to 60 actions in each synchronization request. When you set the value to -1, you remove the limit, which means that a synchronization request can include an infinite number of actions.
pega.offline.Indicator.setDeferDurationTime
- Sets the time (in milliseconds) that must pass from the start of the synchronization session before the Syncing/Synced label appears on the screen. By default, it is set to 4000 ms (4 seconds). The value must be greater than 0.
pega.offline.Indicator.setHideSyncedAfterTime
- Sets the time (in milliseconds) that must pass from the end of the synchronization session before the Synced label disappears from the screen. The default value is 5000 ms (5 seconds). The value must be greater than 0.