Methods
onStoreInitialized(storeName, callback, delay)
Registers a callback function that is called when a session store is initialized. For stores that are initialized several times, specify a callback delay so that the callback function is called only once:
- When the store is initialized during the delay period of a previous initialization, the previous function call is cancelled, and the function is called again for the current initialization.
- If the delay period lapses before a subsequent initialization occurs, the callback function is executed twice.
For example, a session store is based on a JSON object and retrieved via a JSON request. The following intialization scenarios are possible:
- The request is completed, data retrieved and loaded into the store. In this case, initialization occurs once.
- The request fails (timeout). In this case initialization does not happen and there is no data in the store.
- The store is pre-populated with default values (init properties), but the request fails (timeout). There is only one initialization with default values.
- The store is pre-populated.
When the delay is set to true
or several milliseconds, the method waits before calling the callback method. If another initialization event is triggered before the delay is passed, it will wait until the delay time is exceeded with no initialization event. This enables waiting for a second initialization event to be triggered and calls the callback function in the most optimal case.
Parameters
- storeName: String. The name of the session store to add the listener.
- callback: Function. The function to call upon store initialization.
- delay: Boolean or Number. The amount of time to delay the call to the callback function, in milliseconds. A boolean value of
true
uses the default delay of200 ms
. A boolean value offalse
or a negative number causes no delay to be used.
Returns
No returned value.
onStoreRegistered(storeName, callback)
Registers a callback function that is called when a session store is registered. The register event occurs when a store is registered to CQ_Analytics.ClientContextMgr.
Parameters
- storeName: String. The name of the session store to add the listener.
- callback: Function. The function to call upon store initialization.
Returns
No returned value.
CQ_Analytics.JSONPStore
A non-persisted session store that contains JSON data. The data is retrieved from an external JSONP service. Use the getInstance
or getRegisteredInstance
method to create an instance of this class.
Extends CQ_Analytics.JSONStore.
Properties
See CQ_Analytics.JSONStore and CQ_Analytics.SessonStore for inherited properties.
Methods
Also see CQ_Analytics.JSONStore and CQ_Analytics.SessonStore for inherited methods.
getInstance(storeName, serviceURL, dynamicData, deferLoading, loadingCallback)
Creates a CQ_Analytics.JSONPStore object.
Parameters
- storeName: String. The name to use as the STORENAME property. The value of the STOREKEY property is set to storeName with all upper-case characters. If no storeName is provided, the method returns null.
- serviceURL: String. The URL of the JSONP service
- dynamicData: (Optional) Object. JSON data to append to the store’s initialization data before the callback function is called.
- deferLoading: (Optional) Boolean. A value of true prevents the JSONP service from being called upon object creation. A value of false causes the JSONP service to be called.
- loadingCallback: (Optional) String. The name of the function to call for processing the JSONP object that the JSONP service returns. The callback function must define a single parameter that is a CQ_Analytics.JSONPStore object.
Returns
The new CQ_Analytics.JSONPStore object, or null if storeName is null.