Modules inheritance
See original GitHub issueWhen 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:
- Created 4 years ago
- Reactions:22
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm this, inheritance is broken, also for getters and attributes.
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/