championswimmer / vuex-module-decorators

TypeScript/ES7 Decorators to create Vuex modules declaratively
https://championswimmer.in/vuex-module-decorators/
MIT License
1.8k stars 170 forks source link

Conflict with NuxtJS third-party modules #376

Open Tcharlyson opened 3 years ago

Tcharlyson commented 3 years ago

When using store-accessor from the doc in NuxtJS, @Action are working until other library is used as @nuxtjs/auth-next or @nuxtjs/i18n then error is :

Error: ERR_STORE_NOT_PROVIDED: To use getModule(), either the module
            should be decorated with store in decorator, i.e. @Module({store: store}) or
            store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)

Few workarounds exist :

  1. Use @MutationAction instead of @Action seems to work BUT if no mutation is needed or a custom one is required, this is not a solution
  2. Disable vuex for all third-party modules vuex: false BUT we loose the main purpose of using third-party modules
  3. Import manually in all our components like public applicationModule = getModule(ApplicationModule, this.$store) BUT this is obviously time consuming

So how can we make @Action work and how do we explain that @MutationAction is working and not @Action ?

Big thanks !

Tcharlyson commented 3 years ago

When using store-accessor from the doc in NuxtJS, @Action are working until other library is used as @nuxtjs/auth-next or @nuxtjs/i18n then error is :

Error: ERR_STORE_NOT_PROVIDED: To use getModule(), either the module
            should be decorated with store in decorator, i.e. @Module({store: store}) or
            store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)

Few workarounds exist :

  1. Use @MutationAction instead of @Action seems to work BUT if no mutation is needed or a custom one is required, this is not a solution
  2. Disable vuex for all third-party modules vuex: false BUT we loose the main purpose of using third-party modules
  3. Import manually in all our components like public applicationModule = getModule(ApplicationModule, this.$store) BUT this is obviously time consuming

So how can we make @Action work and how do we explain that @MutationAction is working and not @Action ?

Big thanks !

@Action is working until vuex-module-decorators:0.11.0

VPetar commented 2 years ago

@Tcharlyson well, you can mutate inside the function and return a custom object? Anyways, thanks for figuring out at least @MutationAction works 0,o