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.

Impossible to extend module, class

See original GitHub issue

export default abstract class AbstractForm extends VuexModule implements IAbstractForm {
    _fields = {};

    get fields(): { [key: string]: string } {
        return this._fields;
    }
...
@Module({namespaced: true})
export default class SearchForm extends AbstractForm implements ISearchForm {
    /** @override **/
    _fields                = {
        searchValue: ''
    };

@Template
@Component<SearchForm>
export default class SearchForm extends Vue implements ISearchForm, IAbstractForm {
    @namespace(searchFormNamespace).Getter
    fields!: any;


    mounted() {
        console.log(this.fields);
    }

error [vuex] unknown getter: FORMS/FORM_SEARCH/fields

Extended only .State, but actions and getters, mutations not shared, extended

If we declare @Module for child class, child does not inherit methods from parent class. If we declare modules for both classes, child and parent, child class has no it is state fields, but we have both classes methods 😕

We need a way to extend modules or some way to share common features across classes. Writing duplicated code for every module is to heavy to maintain.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

9reactions
BonBonSlickcommented, Jul 1, 2020

I strongly suggest to remove this package and never use it, because it can not be extended without core modification. Tried TS extend, implement, mixins (2 ways, copy with prototyping and extending constructor with decorator), decorators, state factory, dynamic loading.

Maybe, it is awesome if you have 1-2 states, bur reality is, we have more then 25+ modules, most of projects also require extending or share common functionalities. Seems impossible to do without some tricky stuff or messing a lot.

I lost a lot of time, because most of Vue + TS shitty guides use this package. Seems like everyone except me works with small projects with 1-2 pages or do not want to share their tricks with community. I will have now to redo vuex to old way I used before.

6reactions
VitAndrGuidcommented, Dec 8, 2020

Guess i learned a lesson from this aswell, never use a package without seeing the open issues first.

I started to use this in my work, seemed fine until i had to work with inheritance, getters not working, state not getting properly mapped and now i found a bug with namespaced modules, this package is a unmaintained waste of time.

The author knows inheritance is broken and doesnt even mention it in the docs, tricking us to waste time with this package until we inevitably drop it

Read more comments on GitHub >

github_iconTop Results From Across the Web

ruby - How to extend a module on a class dynamically?
I have added the name of the module and passing that to the constructor of the object but complains with the code. class...
Read more >
Document that extending/implementing classes can not be ...
Even if you have a dependency on a module, it's possible that both your module and the dependency are disabled when your .module...
Read more >
Extend external modules declared in @types npm dependency
How do we extend the class defintion of a module?
Read more >
How to Use Inheritance to Extend Classes and Modules in ...
Because it's kinda powerful, here's a quick tutorial on using Inheritance with Python to extend classes and modules. In the second half of ......
Read more >
Ruby Tidbit: Include vs Extend with Module Class Variables
Still, you will at some point find yourself using them, so it's good to understand as much as possible about their behavior. Since...
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