Seems like your NetworkRequest.getData(payload)
function is doing something expensive synchronously. Because JavaScript is single threaded, the next action doesn't happen until this function returns which can cause a lag.
By adding await timeOut(0)
, you no longer make it synchronous. It's now called in the next event loop which means any synchronous actions before that would finish already.