My goal is to have a function called setSource perform an action that takes about 3 seconds to complete.
editor.setSource();
setTimeout(function () {
// Execute additional commands
}, 3000);
I need the section of code labeled "//do something, some commands" to run after the setSource() function has finished executing. Currently, I am achieving this using setTimeout, but I recognize that it may not be the most optimal solution as setSource() could potentially take longer than 3 seconds to execute. How can I ensure that these commands run only after setSource() has completed its task?