Rich-text Reply

addOptimizelyEventListener

anoosh 12-10-15
Accepted Solution

addOptimizelyEventListener

How to get call back for API "Optimizely.refreshExperiments()"

 

Will "Optimizely.refreshExperiments()" always tend to call onOptimizelyDataFileLoaded() ?

 

Looking forward for early reply.

 

Level 2

Re: addOptimizelyEventListener

Hi @anoosh,

 

Great questions!  refreshExperiments() only refreshes local data file, but does not make a new download request over the wire.

 

You can certainly add an event listener to onOptimizelyDataFileLoaded, as described here and here, which is called asynchronously every two minutes as long as the device has an internet connection.  However, if nothing changes in your project, the revision number will not increment and a new data file will not be downloaded.

 

Does this information help?

Harrison Krat
Solutions Architect | Optimizely, Inc.
harrison@optimizely.com
 
anoosh 12-11-15
 

Re: addOptimizelyEventListener

Thanks for the reply.

- Does that mean, refreshExperiments() call will immediately refresh the experiment data and any further reading of LiveVariables should have an updated value ?
Level 2

Re: addOptimizelyEventListener

Yes, for the local version of the data file (i.e. whatever values are in the latest version that has already been downloaded). If the latest file has already been downloaded on the two-minute cadence, and it contains the updated values you expect, then when you call refreshExperiments(), you will see the updated values.
Harrison Krat
Solutions Architect | Optimizely, Inc.
harrison@optimizely.com
 
anoosh 12-11-15
 

Re: addOptimizelyEventListener

Is there an equivalent callback for OptimizelyEventListener --> "onOptimizelyDataFileLoaded() " in iOS ?
Level 2

Re: addOptimizelyEventListener

Hi @anoosh,

 

Yes.  Check out how to subscribe to NSNotifications, and in this case, specifically OptimizelyNewDataFileLoadedNotification.

Harrison Krat
Solutions Architect | Optimizely, Inc.
harrison@optimizely.com