Thread Handling - GameAnalytics/GA-SDK-JAVASCRIPT GitHub Wiki

Almost every piece of this code is run using a dedicated low-priority serial thread queue to avoid UI lag or sudden performance spikes.

The queue will execute each task sequentially. If the SDK add several tasks to the queue then each will be executed in turn. A task could be adding an event or submitting all queued events.

Consider this example with 3 calls.

<!-- Traditional way -->
// Configure build version
gameanalytics.GameAnalytics.configureBuild("alpha 0.1.0");
// Initialize
gameanalytics.GameAnalytics.initialize("12341234123412341234123412341234", "1234123412341234123412341234123412341234");
// Add Design event
gameanalytics.GameAnalytics.addDesignEvent("Some:Event");

<!-- Command queue -->
// Configure build version
GameAnalytics("configureBuild", "alpha 0.1.0");
// Initialize
GameAnalytics("initialize", "12341234123412341234123412341234", "1234123412341234123412341234123412341234");
// Add Design event
GameAnalytics("addDesignEvent", "Some:Event");

The configureBuild is required to be called before initialize is completely finished. The design event call is required after initialize is finished. The queuing will make sure that each task is completely finished before proceeding to the next one.

 

NEXT  →