According to this answer, the code snippet below is taken from the official documentation of vuex-module-decorators
// @/store/index.ts
import Vuex from 'vuex'
const store = new Vuex.Store({
/*
Ideally if all your modules are dynamic
then your store is registered initially
as a completely empty object
*/
})
In the context of Nuxt, the implementation should be:
import Vue from "vue";
import Vuex, { Store } from "vuex";
Vue.use(Vuex);
export const store: Store<unknown> = new Vuex.Store<unknown>({});
However, how can we incorporate the nuxtServerInit
action using the above method?
import Vue from "vue";
import Vuex, { Store } from "vuex";
Vue.use(Vuex);
export const store: Store<unknown> = new Vuex.Store<unknown>({
actions: {
nuxtServerInit(context: unknown): void {
console.log("Called !");
console.log(context);
}
}
});