Skip to content

Instantly share code, notes, and snippets.

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 call
var waitForFlag = setInterval(function() {
if(flag) {
console.log("fire here");
}, 50);
// this is a placeholder for the s.registerPostTrackCallback)() logic;
// consider checking for the call type (make sure it's not an 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");
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment