I have a huge and slow synchronous function which I wish to wrap it inside a promise to use it asynchronously. Although this function contains secondary operations, is good to be executed without get the interface stuck (avoiding the user's rage :D).
What I did is the following (commons.js, separate javascript file):
exports default {
myHugeFunction: function(params) {
//lots...lots...lots..of synchronous things
}
}
Where I call it?
Vuejs store module
import commons from '/path/to/commons'
export default {
actions: {
updateInterface: function() {
//overlay on
//some syncronous stuff...
Q.fcall(function () {
commons.myHugeFunction(params);
}
//some others syncronous stuff...
//overlay off
}
}
}
Even so, it seems to work fine but I got the entire frontend stuck since the huge function has finished. I use to put an overlay before the execution and after that but i can't see it eve if there's in the dom (but that's probably another out of scope problem...).
I imagine it's execution like something that could be handled by a separate thread so the user, during this time, can do others stuff.
Is because "maybe" the application is entirely in the front-end (browser)?