-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Description
What problem does this feature solve?
There may be situations in which you have to use multiple nextTick
calls in a single function. In this case, using ES8's async/await functionality is very useful, as it can prevent overly nested, unreadable code.
Right now, I have to use either this:
async myMethod() {
// code before first nextTick call
await new Promise(resolve => this.$nextTick(resolve));
// code before second nextTick call
await new Promise(resolve => this.$nextTick(resolve)); // ugly :(
// code after
}
Or this:
myMethod() {
// code before first nextTick call
this.$nextTick(() => {
// code before second nextTick call
this.$nextTick(() => { // ugly nesting :(
// code after
});
});
}
What does the proposed API look like?
nextTick
should return a Promise. It may also take a closure as a parameter for compatibility reasons.
You could then use all three variants:
this.$nextTick(() => /* my code after */);
this.$nextTick().then(() => /* my code after */);
await this.$nextTick();
/* my code after*/
Metadata
Metadata
Assignees
Labels
No labels