ktsn / vuex-class

Binding helpers for Vuex and vue-class-component
MIT License
1.73k stars 86 forks source link

Possibility to access the rootState? #25

Closed Mawster closed 6 years ago

Mawster commented 6 years ago

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 6 years ago

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