Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// default the flag to false (it gets set to true in registerPostTrackCallback)
var flag = false;
// wait for flag=true (set in registerPostTrackCallback) to fire the s.tl() call
var waitForFlag = setInterval(function() {
if(flag) {
console.log("fire s.tl() here");
clearInterval(waitForFlag);
}
}, 50);
// this is a placeholder for the s.registerPostTrackCallback)() logic;
// consider checking for the call type (make sure it's not an s.tl() call) before
// setting flag=true
function pretendThisIsRegisterPostTrackCallback() {
console.log("in registerPostTrackCallback; setting flag=true");
flag = true;
}
// this is just a delay to fire the s.t() call after a couple of seconds;
// in your scenario, this would be the actual s.t() call
setTimeout(function() {
console.log("fire s.t() here");
pretendThisIsRegisterPostTrackCallback();
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.