1.0.2 • Published 3 years ago

vuex-exact v1.0.2

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

vuex-exact

Aim

The package is aiming for strongly typing vuex store for better development experience

Install

npm i vuex-exact

Usage

import Vue from 'vue'
import Vuex from 'vuex'
import { UnpackStore, ActionContext, MapActionsType, MapStateType, MapGettersType, MapMutationsType } from 'vuex-exact'

const options = {
    state: {
        example: 0
    },
    mutations:{
        mute: (state: any, payload: string) => {}
    }
    /*store options*/
}

export default new Vuex.Store(options)

export type StoreOptions = typeof options
export type StoreState = typeof options.state
export type StoreType = UnpackStore<StoreState, StoreOptions> // Store Type 
export type MainActionsContext = ActionContext<StoreState, StoreOptions> // context of actions outside modules
export type MapActions = MapActionsType<StoreState, StoreOptions> // typeof mapActions
export type MapState = MapStateType<StoreState, StoreOptions> // typeof mapState
export type MapGetters = MapGettersType<StoreState, StoreOptions> // typeof mapGetters
export type MapMutations = MapMutationsType<StoreState, StoreOptions> // typeof mapMutations

getting module action context

import Vue from 'vue'
import Vuex from 'vuex'
import { ActionContextModule } from 'vuex-exact'
import { StoreState, StoreOptions } from "" //main Store file location
const moduleOptions = {
    state: {
        example: 0
    },
    mutations:{
        mute: (state: any, payload: string) => {}
    }
}
export moduleOptions
export type ActionContext = ActionContextModule<typeof moduleOptions.state ,StoreState, typeof moduleOptions,StoreOptions>
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago