Web SDK Lifecycle Callbacks

There are cases where you might want to wait for the SDK to be initialised completely to do some action. Or you may need to trigger something when the SDK settings are fetched (cached in the browser for 24 hours). SDK emits events on its various life cycles which can be listened to use it.

JavaScript
window.addEventListener("MOE_LIFECYCLE",function(e){
if(e.detail.name === "SDK_INITIALIZED"){
console.log(e.detail.data)
// write you code here
}
if(e.detail.name === "SETTINGS_FETCHED"){
console.log(e.detail.data)
// write you code here
}
})

 

Was this article helpful?
0 out of 2 found this helpful

How can we improve this article?