Skip to content

Commit c1dbf54

Browse files
committed
Fixed nuxt integration issues
1 parent 24ed31b commit c1dbf54

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/interfaces.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export type DictionaryField = string | number | symbol
5959

6060
export interface VuexObject {
6161
namespaced :boolean | undefined;
62-
state :Record<DictionaryField, any>
63-
mutations :Record<DictionaryField, any>
64-
getters :Record<DictionaryField, any>
65-
actions :Record<DictionaryField, any>
62+
state :Map | (() => Map);
63+
mutations :Map
64+
getters :Map
65+
actions :Map
6666
modules :Record<DictionaryField, VuexObject>
6767
}
6868

src/proxy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ export function _createProxy<T extends typeof VuexModule>(cls: T, $store: any, n
116116
const proxy :Map = {};
117117

118118
const classPath = getClassPath( VuexClass.prototype.__namespacedPath__ ) || toCamelCase( VuexClass.name );
119-
const { state, mutations, actions, getters, modules } = extractVuexModule( VuexClass )[ classPath ];
119+
let { state, mutations, actions, getters, modules } = extractVuexModule( VuexClass )[ classPath ];
120+
121+
// For nuxt support state returns as a function
122+
// We need to handle this.
123+
if( typeof state === "function" ) state = state();
120124

121125
createGettersAndMutationProxyFromState({ cls: VuexClass, proxy, state, $store, namespacedPath });
122126
createGettersAndGetterMutationsProxy({ cls: VuexClass, mutations, getters, proxy, $store, namespacedPath });

0 commit comments

Comments
 (0)