I am writing a webpage with the following structure:
In order to guarantee correctness, the table need to be updated only after the other table is fully updated (i.e., done with computation). However, I don't know how to effectively achieve this, and I could not find any wait
facility within JavaScript.
For now, I am using the following method:
updated
and make it false
;while
loop until updated
is true
;updated
to true
.This seems unintuitive to me but I cannot think of any other way of doing it. Is there any good ways to do this?
Thanks for any inputs!
Add an listener, once the calculation is done and the event received, set updated to true.
Instead of setting updated
to true, and then waiting for updated
to be true- just do whatever you want to do in the listener.
myEventBus.addListener(function () {
// do whatever
updateTable();
alert('table updated!');
});