Vuex-module-decorators: How can I use a constructor in a module?

Created on 17 Mar 2019  Â·  5Comments  Â·  Source: championswimmer/vuex-module-decorators

I need to do some initialization work whenever the module is constructed.
But when I add the super(); call, it expects a module parameter.
What should I pass in there?

@Module
export default class RealTime extends VuexModule {
    private playersOnline!: [];

    constructor() {
        super();
    }

    get getPlayersOnline() {
        return this.playersOnline;
    }
}; 

constructor VuexModule, any>(module: Module, any>): VuexModule, any>
Expected 1 arguments, but got 0.ts(2554)
vuexmodule.d.ts(16, 17): An argument for 'module' was not provided.

Most helpful comment

Modules are not supposed to be constructed. Use getModule() to fetch a module object.

This prevents me from using DI (inversify.js) with modules.

All 5 comments

Modules are not supposed to be constructed. Use getModule() to fetch a
module object.

On Mon 18 Mar, 2019, 1:13 AM Magnus Johansson, notifications@github.com
wrote:

I need to do some initialization work whenever the module is constructed.
But when I add the super(); call, it expects a module parameter.
What should I pass in there?

@Moduleexport default class RealTime extends VuexModule {
private playersOnline!: [];

constructor() {
    super();
}

get getPlayersOnline() {
    return this.playersOnline;
}

};

constructor VuexModule(module: Module):
VuexModule
Expected 1 arguments, but got 0.ts(2554)
vuexmodule.d.ts(16, 17): An argument for 'module' was not provided.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/championswimmer/vuex-module-decorators/issues/105,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQ_yiXDwsGJZAMc_22MJgfVjqcaGYGDks5vXpr3gaJpZM4b4mOf
.

Modules are not supposed to be constructed. Use getModule() to fetch a module object.

This prevents me from using DI (inversify.js) with modules.

Modules are not supposed to be constructed. Use getModule() to fetch a module object.

This prevents me from using DI (inversify.js) with modules.

It's wonderfull thing but look - if you want to inject something (this real cool to inject service to module and use it in MutationAction) - you can't

And if you need to get a module, but for some reason can't because of an unresolved issue https://github.com/championswimmer/vuex-module-decorators/issues/266 ?

I need to get my authStore, but can't use getModule() since it seems to break the webpack output.... The workaround would be to call my static class from the constructor and pass the module as an argument to get it where I need it for now.

Modules are not supposed to be constructed. Use getModule() to fetch a module object.

This prevents me from using DI (inversify.js) with modules.

It's wonderfull thing but look - if you want to inject something (this real cool to inject service to module and use it in MutationAction) - you can't

This makes me sad.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Akumzy picture Akumzy  Â·  5Comments

davidhiendl picture davidhiendl  Â·  3Comments

Hamidrezana picture Hamidrezana  Â·  4Comments

stevefan1999-personal picture stevefan1999-personal  Â·  5Comments

blainehansen picture blainehansen  Â·  4Comments