ktsn/vuex-class

Possibility to access the rootState?

Closed this issue · 1 comments

From an example (https://codeburst.io/vuex-and-typescript-3427ba78cfa8):

// index.ts
import Vue from 'vue';
import Vuex, { StoreOptions } from 'vuex';
import { RootState } from './types';
import { profile } from './profile/index';

Vue.use(Vuex);

const store: StoreOptions<RootState> = {
    state: {
        version: '1.0.0' // a simple property
    },
    modules: {
        profile
    }
};

export default new Vuex.Store<RootState>(store);

We have the profile module and it works fine to inject it with
@State('profile') profileState

But is there a possibility to get the RootState?
like:
@State('root') rootState

ktsn commented

No, since State decorator is for mapping sub state to computed property. You should just use this.$store.state