Skip to content

Instantly share code, notes, and snippets.

@hitGovernor
Last active September 30, 2020 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitGovernor/dc3e7120830a9feaea16c6840715d36c to your computer and use it in GitHub Desktop.
Save hitGovernor/dc3e7120830a9feaea16c6840715d36c to your computer and use it in GitHub Desktop.
// 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