Git Product home page Git Product logo

Comments (8)

michaelolof avatar michaelolof commented on May 29, 2024 1

This issue has been resolved in the latest version

from vuex-class-component.

SaphuA avatar SaphuA commented on May 29, 2024

It seems like the options are used of the last extracted module, or something like that...

export class StoreA extends createModule({ namespaced: "StoreA", strict: true }) { }
export class StoreB extends createModule({ namespaced: "StoreB", strict: true }) { }
console.log(extractVuexModule(StoreA));
console.log(extractVuexModule(StoreB));
export class StoreC extends createModule({ namespaced: "StoreC", strict: true }) { }
console.log(extractVuexModule(StoreA));
console.log(extractVuexModule(StoreB));
console.log(extractVuexModule(StoreC));

prints

{StoreB: {…}}
{StoreB: {…}}
{StoreB: {…}}
{StoreB: {…}}
{StoreC: {…}}

from vuex-class-component.

SaphuA avatar SaphuA commented on May 29, 2024

Seems very likely this has something to do because you're using the prototype here, which is always VuexModule:

(VuexModule as VuexModuleConstructor).prototype.__options__ = options;

from vuex-class-component.

michaelolof avatar michaelolof commented on May 29, 2024

Mind sharing a sample project so I can replicate your issue.

Thanks

from vuex-class-component.

SaphuA avatar SaphuA commented on May 29, 2024

Here you go. I've added some console.log's to src/store.ts

yarn install
yarn serve

https://github.com/SaphuA/vuex-class-component-ns-repro

from vuex-class-component.

SaphuA avatar SaphuA commented on May 29, 2024

Looks ok! I'll do some more testing this week.

from vuex-class-component.

SaphuA avatar SaphuA commented on May 29, 2024

So when exactly should one use createModule and when With for providing options?

from vuex-class-component.

michaelolof avatar michaelolof commented on May 29, 2024

With is useful for extending already defined options.

Ideally you want to create a base configuration like so:

const VuexModule = createModule({
  strict: false,
  target: "nuxt",
  enableLocalWatchers: true,
})

export class UserStore extends VuexModule.With({ namespaced: "user", strict: true }) {
}

Think of it as a 2 level inheritance for your module options.

from vuex-class-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.