@sdetweil said in Making persistent and smooth visual timer:
u can use
document.getElementByClassName(className)
or
document.getElementById(id)so u can know it it exists…
it won’t til you pass thru getdom once probably
That’s what im doing. The issue is that without a callback from the getDOM you would probably have to loop that part.
Following flow: The node_helper sends the socketnotification with the code for authentification. The dom updates to show this auth code and adds the div for the timer. When I call
this.updateDom();
initializeTimer();
I will get that the current element with the id doesn’t exist since the initializeTimer
executes before the dom is ready. So I would need to loop that until the dom is ready to add the timer onto it. Which is obviously a terrible idea. So having a callback or a promise would make that a lot easier. Because currently I would need to do something like that:
this.updateDom();
setTimeout(function() {
initializeTimer();
}, 1000);
And pray that the dom changes already happened.