Comments (3)
The simplest implementation would be having VuexModule
as:
export class VuexModule {
private __options: RegisterOptions;
constructor(options: RegisterOptions | ((className: string) => RegisterOptions)) {
if (typeof options === "function") {
options = options(this.constructor.name);
}
this.__options = options;
}
}
The problem with using this.constructor.name
is that in the minified version it will be mangled. Maybe multiple different classes might even get the same name then
from vuex-class-modules.
I don't see any use cases other than DI where you wouldn't want to add a name when registering the modules (for instance in Vue Devtools you would like to be able to identify the modules). Vuex' store.registerModule
also requires a name (path).
As you mention, using constructor.name
has the problem that it will be mangled when minified, and I'm not sure the names will be unique, so I don't like this solution.
For your need, can't you just change the constructor of your modules to something like:
@Module
class MyModule extends VuexModule {
constructor(store: Store) {
super({ store, name: "myModule" })
}
}
?
from vuex-class-modules.
This might not pose an immediate problem, but it goes against the principles of dependency injection, because then every module must make sure not to collide with any other.
When I said, using the module class, I meant “based on the module class”. So some uid could be added.
Anyway, I can of course define my own constructor, which allows the options factory and calls it before invoking super
. So it’s ok that this is not changed here.
from vuex-class-modules.
Related Issues (20)
- [Question] Module Watching other module value, and initial state setting HOT 5
- Cannot read property 'state' of undefined HOT 8
- Request for new feature - @Onload method decorator HOT 2
- [Feature Request] Vuex Child Modules Functionality (Submodules) HOT 4
- jest typescript fails HOT 4
- How to access Store extensions in 'this' instance? HOT 2
- Allow usage in node app without babel HOT 2
- Vuex 4 (Vue 3) support HOT 2
- Error when using hmr with vite HOT 6
- Add support for unregisterModule HOT 1
- Don't know where else to say this, but...
- Status of Vue 3.x and Vuex 4.x support ? HOT 1
- Allow composition of Action, Mutation and Getter HOT 3
- fully support registerModule usage HOT 1
- Access generated mutations (generateMutationSetters: true) from module instance HOT 3
- Is there a way to register the module without namespace? HOT 2
- Vue Devtools not working HOT 4
- List of refactoring tasks HOT 2
- Question: how to persist state? HOT 3
- How to passing multiple arguments to @action HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-class-modules.