I have an async watch that fetches some data from the server. It will batch process the Response in a blocking operation. I am trying to update the view before kicking off the blocking operation, like so:
Vue.component("foo-bar", {
...
watch: {
async things() {
const response = await API.getThings();
this.someUIMessage = `processing ${response.length} things...`;
someBlockingOperation(response);
}
}
}
But this.someUIMessage
is not updated in the view until after someBlockingOperation
. I stuck an await Vue.nextTick()
in between setting the string and calling the blocking op, and this.$forceUpdate()
, but without success.
What does work (sometimes! depends on what else is going on in the app) is calling setTimeout(() => someBlockingOperation(response), 0)
, but that seems like a kludge. Is there a step I'm missing?