Skip to content

Commit 8fcc243

Browse files
committed
For #266: add dynamic property to store interfaces to match #272 fixes, update docs with non-spread usage example
1 parent 4ef4ea9 commit 8fcc243

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/pages/en/2.accessor/2.dynamic-modules.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ for large projects with no able of using `useAccessor` as variable.
7373
```ts{}[store/index.ts]
7474
import * as myImportedModule from '~/modules/myImportedModule'
7575
import * as myNestedModule from '~/modules/myNestedModule'
76+
import * as myDynamicModuleNoSpread from '~/modules/myImportedModuleNoSpread'
7677
7778
export const accessorType = getAccessorType({
7879
state,
@@ -83,15 +84,27 @@ export const accessorType = getAccessorType({
8384
submodule: {
8485
//add this for module to show as possibly-undefined when using $accessor
8586
dynamic: true,
87+
namespaced: true,
8688
...myImportedModule,
8789
modules: {
8890
myNestedModule,
8991
},
9092
},
93+
//You can add `export const dynamic = true;` inside module so you don't need to use spread operator in that case
94+
//View the example below
95+
submoduleWithoutSpread: myDynamicModuleNoSpread,
9196
},
9297
})
9398
```
9499

100+
```ts{}[modules/myImportedModuleNoSpread.ts]
101+
export const dynamic = true;
102+
103+
export const state = () => ({
104+
//...
105+
});
106+
```
107+
95108
### Modules registration
96109

97110
```ts{}[components/my-component.vue]

packages/typed-vuex/src/types/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface BlankStore {
1616
mutations: {}
1717
actions: {}
1818
modules: {}
19+
dynamic: boolean
1920
}
2021

2122
export interface NuxtStore {
@@ -24,6 +25,7 @@ export interface NuxtStore {
2425
mutations: Record<string, any>
2526
actions: Record<string, any>
2627
modules: NuxtModules
28+
dynamic: boolean
2729
}
2830

2931
export interface ExtendedNuxtStore extends NuxtStore {
@@ -37,6 +39,7 @@ export interface NuxtStoreInput<
3739
A,
3840
S extends { [key: string]: Partial<ExtendedNuxtStore> }
3941
> {
42+
dynamic?: boolean
4043
namespaced?: boolean
4144
state: T
4245
getters?: G

0 commit comments

Comments
 (0)