addListener


Purpose

Adds a listener to the Client Store service.

Signature

addListener( callbacks )

Returns

This method does not return anything.

Parameters

Name Description Type Use
callbacks An object where all the callbacks are defined. object required

The addListener method's callbacks object is structured as follows:

{
  onActionAdded: function(), {...}
  onStatusUpdate: function( status ), {...}
  onProgress: function( progress, phase ), {...}
  inactivityTimeoutPassed: function() {...}
}

The onActionAdded callback is called when an action is added to the action queue.

The onStatusUpdate callback is called when the API needs to report its state. The callback receives the status JSON object as its call parameter representing the current Store and Forward process status, consisting of the following parameters:

Name Description Type
busy Represents the Client Store service's state: "true" if synchronization is running and "false" if it is idle. boolean
event Defines event that caused the Client Store's status update as defined in the Constants table in the Client Store article, and an error message. Undefined if no status update has occurred. constant
upsertedItems A map of types registered with "reportChangesForTypes" vs. arrays of handles of all inserted or updated synchronization items. Undefined for events other than SUCCEEDED. object
deletedItems A map of types registered with "reportChangesForTypes" vs. arrays of handles of all deleted synchronization items. Undefined for events other than SUCCEEDED. object
modifiedCustomTables An array of custom tables that were modified as a result of the delta synchronization. If there are no modified custom tables or the full synchronization command was invoked, an empty array is returned. Undefined for events other than SUCCEEDED. object
wasFullSync A value that is set to true if full synchronization operation was performed. This indicates that all items and custom tables were modified. boolean
lastErrorCode Specifies the type of error of last failure as defined in the Constants table in the Client Store article, and an error message. Undefined if no error has occurred. Updated accordingly by SUCCEEDED or FAILED events. constant
lastErrorMessage Represents a human-readable description of the type of failure. Updated accordingly by SUCCEEDED or FAILED events. string

The onProgress callback is called when the synchronization process is in progress. The callback receives the following properties as its call parameters:

Name Description Type
progress A number from the 0 - 100 range, indicating the synchronisation progress. number
phase Specifies the data synchronization status, as defined in the Progress table of the Constants section in the Client Store article, and an error message. Undefined if no phase change occurred. constant

The inactivityTimeoutPassed callback is called after a time of inactivity has passed that is set by using the configure method. This callback has no parameters.

Related topics

Client Store
Legal notice | Copyright © 2017 and Confidential to Pegasystems Inc. All rights reserved
PDN | Feedback
Advanced...