Description
What problem does this feature solve?
In an event handler, one can easily mix property modifications and method calls (which is great), as in:
<span @click=" accumulator += fetchNextItem() ">do it</span>
However, if the called method is async, one need to actually wrap this code in an additional method like:
<span @click=" fetchAndAccumulateNextItem() ">do it </span>
....
methods: {
async fetchAndAccumulateNextItem() {
this.accumulator += await this.fetchNextItem()
},
async fetchNextItem() { .... } /* unmodified */
}
This can be slightly inconvenient if there are many asynchronous methods of which we use the return value.
I think this might become more and more common as people start understanding and using async/await more and more.
Initial context: I have a very specific use case of a vuejs<->python bridge that makes (among other things) all the python-written method callable from vuejs, but as the call goes through websockets, all methods end up async. https://github.com/twitwi/vuejs-python
What does the proposed API look like?
I'd suggest a ".async" modifier that would allow for "await" in the event handler snippet.
For the example above, it would be written as:
<span @click.async=" accumulator += await fetchNextItem() ">do it</span>
(this is probably useful for all types of events, not only click)