question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

constructor vuex - module

See original GitHub issue

I am trying to inject my class which extends VuexModule using a DI container based on inversifyjs.

I Would have to pass the VuexModule constructor to the DI container then inject it when the class is instantiated to be passed to super().

It would be helpful if you could provide an example of :

/*

  • To use with new VuexModule(<ModuleOptions>{}) syntax

*/

cheers.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gregverescommented, Nov 20, 2019

@orgertot I believe the answer you were looking for was provided here on issue #105. The answer from @championswimmer was that you shouldn’t be using the constructor syntax of typescript for your Modules. I find that answer very unsatisfactory since that is our style guide - we do all of our initialization inside constructors and then we unit test the constructor setup the class properly.

I think that @championswimmer answered your question with his example of how he would do unit testing on a store module, by creating the store, then sending it messages. That’s not really how I would prefer to test my modules, but if you can’t instantiate them, then I guess that is the best we can do.

I know your original question was a long time ago and you have probably found another way around this. I am just migrating to vue from another framework where we have lots of existing typescript code that is all unit tested. I am just trying to figure out the best way to do the migration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I use a constructor in a module? · Issue #105 - GitHub
I need to do some initialization work whenever the module is constructed. But when I add the super(); call, it expects a module...
Read more >
API Reference | Vuex
Store Constructor Options #. state #. type: Object | Function. The root state object for the Vuex store.
Read more >
Overview | vuex-module-decorators - championswimmer
Typescript/ES7 Decorators to make Vuex modules a breeze. ... /app/store/posts.ts import { VuexModule, Module, Mutation, Action } from ...
Read more >
Way to make inheritance in Vuex modules - Stack Overflow
I put my reusable vuex code in small classes. E.g.. crud.js export default class { constructor ( endpoint ) { this.state = {...
Read more >
vuex-class-modules - npm
Typescript class decorators for class-style vuex modules. ... The other module can be registered through the constructor (suitable if the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found