Search code examples
androidoptimizely

When to use startOptimizelyAsync() method from Optimizely Android SDK


The Android SDK for Optimizely includes the method Optimizely.startOptimizelyAsnyc()

However, the only documentation for it exists here and is quite lacking. I can't find any other documentation or mention of it on the web.

I would like to use this method instead of the regular startOptimizely recommended in the quickstart, because I'd like the web request to occur asynchronously instead of relying on the 2.5-second timeout. Are there any risks or downsides to using the async method?

Also, I am not interested in any callbacks. Is it ok to pass in null for the callback listener argument?

So far, I am using this method and passing null for the callback and everything SEEMS to be working smoothly. But I'd like to know for sure if this may cause any unpleasant surprises down the line.

Thank you!


Solution

  • The Optimizely folks answered my question on their community forum post:

    https://community.optimizely.com/t5/Mobile-Apps/Android-when-to-use-startOptimizelyAsync/m-p/10906#M120

    Null is a perfectly acceptable value for the callback, we're very careful about handling null inputs on our APIs.

    The downside to using the Async start (especially without a listener) is that you may evaluate live variables or code blocks before Optimizely has started, which means that those values will be locked to to the default value, preventing the experiment from starting. I would recommend using a callback and listening for the onOptimizelyStarted() event.