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.

Modules inheritance

See original GitHub issue

When I try to extend module B from module A, I get state of A

@Module
class Collection extends VuexModule {
    url = "/collection";
    items = [];

}

@Module({ namespaced: true, name: 'owners' })
class Owners extends Collection {
    url = "/owners";
}

In this case Collection is abstract class for another modules. And Owner will have url /collection, that is not correct

So, I discovered deeper and figured out this line doesn’t not call: https://github.com/championswimmer/vuex-module-decorators/blob/a57bb0c767616846d4b31f6d2fea229b85c00167/src/module/index.ts#L18 Because parent already have state.

Therefore i removed @Module notation from Collection class and it works as expected. But! What if I need to inherit module from another module?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:22
  • Comments:5

github_iconTop GitHub Comments

3reactions
sefluecommented, Aug 12, 2020

I can confirm this, inheritance is broken, also for getters and attributes.

0reactions
ddannenbcommented, Mar 8, 2022

Not much value in this lib if inheritance is broken. Pull request with fix is coming up on 2 years old. Alternative: https://vuejsdevelopers.com/2020/10/05/composition-api-vuex/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modules vs Inheritance in Object Oriented Programming
The first of which, Inheritance, is based on the idea that you are making a new class based on an existing one. The...
Read more >
Class Inheritance VS Modules in Ruby - DEV Community ‍ ‍
Inheritance between classes in Ruby allows for the creation of classes that have access to shared methods while still maintaining distinct, ...
Read more >
Inheritance in modules | Modular Programming with JavaScript
There are various ways of creating inheritance among modules and we will examine two of these approaches in this section.
Read more >
Ruby programing tutorial - class inheritance & modules
Inheritance is when a class inherits behavior from another class. ... You can mix in as many modules (interface inheritance) as you'd like....
Read more >
Field Inheritance | Contributed modules - Drupal
The Field Inheritance module can be considered to be a field-level entity reference alternative. It allows site administrators to inherit ...
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