vuex-class-component icon indicating copy to clipboard operation
vuex-class-component copied to clipboard

[Bug] Actions force you to be async

Open robertofd1995 opened this issue 5 years ago • 2 comments

I am creating a new project with Nuxt and I have added your library (thanks for your work by the way ;) ) but there is a problem with the Action decorator.

It force me all the time to return promises even if I don't want to.

For example in this piece of code:

  @action test() {
    console.log('IP UP UASD!')
    return 1
  }

I get the following error:

Captura de pantalla 2020-04-20 a las 9 44 38

So even If I don't put the async there and I ignore the error suppressing it with // @ts-ignore, when I use it in my component I get a promise, and again I am force to put async and await inside the method of the component without sense.

I guess this is fault of the types, but I try to take a look and see If I could create a pull request to fix it but I am not that proficient with Typescript and how the decorators work.

How can I make it work with as a non async action?

Thanks in advance.

robertofd1995 avatar Apr 20 '20 07:04 robertofd1995

I do have the same problem...

samuil4 avatar Apr 30 '20 15:04 samuil4

Vuex actions always returns a promise, it's in the documentation, so I think it's because of that.

nunonux avatar May 06 '20 06:05 nunonux