I have a simple tensorflow.js application built with jquery and some basic javascript.
I have button that when clicked, disables itself and toggles a spinner icon to indicate that the model is performing its predictions. When the predictions are finished the default button is restored. However, visually, the UI is not behaving in this way on the browser.
Demo: https://maksimdan.github.io/endpoints/models/pokename.htm
If we substitute predictions with a synchronous sleep function, it behaves as expected.
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
$("#raw-gen-button").click(async function(){
console.log("Generating new predictions...");
showButtonId("#generating-button");
await sleep(750);
// let predictions = await predict_model(5);
// addGeneratedNamesToUI(predictions);
showButtonId("#generate-button");
console.log("Finished generating new predictions...");
// console.log(predictions);
});