Data synchronization JavaScript API

When using custom JavaScript scripts in an offline-enabled application, you can configure and delay data synchronization by calling several JavaScript methods.

Synchronization happens after a single action appears in the ClientStore action queue. The JavaScript API shown below delays synchronization for a set time or until a certain number of actions are in the queue.

To configure and delay data synchronization, use the following JavaScript methods:

  • pega.offline.DataSync.setIntervalBetweenSynchronizationsWhenServerAccessible - Sets the interval (in milliseconds) between subsequent synchronization sessions when the server is available. The default value is 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 1 minute. The value must be greater than 0.
  • pega.offline.Indicator.setDeferDurationTime - Sets the time (in milliseconds) that must pass from the start of the synchronization session before the Syncing/Synced label is displayed. By default, it is set to 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 is no longer displayed. The default value is 5 seconds. The value must be greater than 0.
  • pega.offline.DataSync.setQueueMaxSize - Sets the number of actions in the queue that must be reached before synchronization is triggered. The default value is 1, which means that actions are immediately sent to the server after they are added to the queue.
  • pega.offline.DataSync.setQueueFlushInterval – Sets the amount of time (in milliseconds) that must pass from the moment when an action is queued in the client store before synchronization is triggered. The default value is 0, which means that synchronization is not delayed.
  • 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 60 actions are sent in each synchronization request. Specifying a value of -1 removes the limit, which means that a synchronization request can include an infinite number of actions.