Vuex-module-decorators: Split a module into multiple files

Created on 30 Oct 2018  路  7Comments  路  Source: championswimmer/vuex-module-decorators

Is it possible to split a module into multiple files?

It is common to write a Vuex module with 5 files where you have module.state.ts, module.getters.ts, module.mutations.ts, module.actions.ts and module.ts (which assembles the 4 files into the same module).

Most helpful comment

it is not good that too many code in a single file. 馃槶

All 7 comments

Not possible with this right now

Closing the issue? Isn't it a possible feature to implement someday?

I don't think it will be possible with the kind of syntax we have. The module class has to be a single file. Otherwise the class decorator will not work.

it is not good that too many code in a single file. 馃槶

Still no work around the use of multiple files for a module?

Hey there, any way to split the module into separate files? This is really needed :/

Hey there, any way to split the module into separate files? This is really needed :/

Well as a work around that I'm using right now is to use a more functional aproach and using helper functions to call methods that are too big to be in that file, so something like:

// helpers.ts
export async function login (request) {
    // do stuff and return a promise
}

// auth.ts
import { login } from "./helpers";

@Action
async login(request) {
    const res = await login(request);
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyberflohr picture cyberflohr  路  4Comments

blackmad picture blackmad  路  4Comments

Leandro-Albano picture Leandro-Albano  路  3Comments

darthf1 picture darthf1  路  5Comments

stevefan1999-personal picture stevefan1999-personal  路  5Comments