Is it possible to update DOM during a work heavy function being run?
So I ran into a problem with a small little thing I'm building. The user clicks a "calculate" button and the computation is pretty heavy and can take upwards to 3-4 seconds so I would like to indicate to the user that something is happening by adding a spinning icon or something.
Simplified example: http://ift.tt/2tV5NwX
I'm not really sure why run1 works as intended, I discovered that when I tried to reproduce the problem by using setTimeout, but it actually worked instead. But run2 is pretty accurate to what is happening in my code, I run through a very big for loop that takes alot of time and I would like to update the DOM before it runs to tell the user that the input was registered and it's working on it.
I tried making run2 return a promise but that made no difference for me. Thanks!
Submitted July 15, 2017 at 11:05PM by Fruntimmer
via reddit http://ift.tt/2trbSha