Skip to content

[feature-request] async/await methods in Vue 2.0 #3308

@nickmessing

Description

@nickmessing

Hey, starting with koa on back-end, a lot of stuff are moving to async/await (*/yield for now), what I suggest is adding async/await functions support to methods so it's allowed to do like:

import DBService from './db'
new Vue({
  el: document.body,
  data: {
    user: {},
    friends: []
  },
  methods: {
    async getUserData () {
      this.user = await DBService.getUser()
      this.friends = await DBService.getFriends(this.user.id)
    }
  }
})

This looks like a cleaner way of doing async stuff to me, what do you think?

P.S. Same can be used for Vuex actions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions