0👍
you would have to wrap the expensive function in a promise, or at least a timeout.
someMethod() {
var _this = this
this.setnewClassHere
var mypromise = new Promise(function(resolve, reject) {
_this.expensiveFunction() // will runy async, so the above setNewClassHere will have effect before expensiveFunction is finished.
resolve() // resolve the promise. This will execute the follwing .then() function.
})
.then(function(result) {
_this.setBackTheClassHere
// when async operation is finished, we set back the class
// no idea if you need this in your case.
})
}
Source:stackexchange.com