vuex-context
Write fully type inferred Vuex modules:
- Extremely lightweight
- No boilerplate
- No class
- Handles module refactoring
Install
-
Install vuex
npm install vuex --save
-
Install module:
npm install vuex-context --save
Usage
- Write your Vuex modules in the standard Vuex way:
; ; ; ;
- Create the module's context
;
- That's it, now you have access to a completely typed version of your module
// Use store and the namespace leading to the module to get a new context instance;counterModule.dispatch.incrementAsync; // Or use the context to access the current scope; // You can also type your getters
Circular references
Warning: Be careful when returning values from your actions and getters!
;
To avoid this, you should manually write the return types of your actions and getters:
;
Contributors
If you are interested and want to help out, don't hesitate to contact me or to create a pull request with your fixes / features.
The project now also contains samples that you can use to directly test out your features during development.
-
Clone the repository
-
Install dependencies
npm install
-
Launch samples
npm run serve
-
Launch unit tests situated in ./tests. The unit tests are written in Jest.
npm run test:unit
License
This project is licensed under the MIT License - see the LICENSE.md file for details