vuex-composition-helpers
Advanced tools
Comparing version 1.0.23 to 1.0.24
@@ -6,2 +6,5 @@ import { computed } from '@vue/composition-api'; | ||
} | ||
export function useStore() { | ||
return getStoreFromInstance(); | ||
} | ||
export function useState(storeOrMap, map) { | ||
@@ -8,0 +11,0 @@ let store = storeOrMap; |
import { Store } from 'vuex/types'; | ||
import { ExtractGetterTypes, ExtractTypes, KnownKeys, RefTypes } from './util'; | ||
export declare function useStore<TState = any>(): Store<TState>; | ||
export declare function useState<TState = any>(storeOrMap: Store<TState> | KnownKeys<TState>[], map?: KnownKeys<TState>[]): RefTypes<TState>; | ||
@@ -4,0 +5,0 @@ export declare function useGetters<TGetters = any>(storeOrMap: Store<any> | KnownKeys<TGetters>[], map?: KnownKeys<TGetters>[]): ExtractGetterTypes<TGetters>; |
{ | ||
"name": "vuex-composition-helpers", | ||
"version": "1.0.23", | ||
"version": "1.0.24", | ||
"description": "Helpers to use Vuex store form Vue Composition API", | ||
@@ -5,0 +5,0 @@ "author": "David Meir-Levy <davidmeirlevy@gmail.com>", |
@@ -128,2 +128,32 @@ # vuex-composition-helpers | ||
#### Typescript Namespaced Usage Example | ||
```ts | ||
import { useState, useActions } from 'vuex-composition-helpers'; | ||
import { ModuleState, ModuleGetters, ModuleActions, ModuleMutations } from "../store/subModule" | ||
export default { | ||
props: { | ||
articleId: String | ||
}, | ||
setup(props) { | ||
const { useState, useActions } = createNamespacedHelpers< | ||
ModuleState, | ||
ModuleGetters, | ||
ModuleActions, | ||
ModuleMutations | ||
>('articles'); // specific module name and generics | ||
const { fetch } = useActions(['fetch']); // no generics needed any more | ||
const { article, comments } = useGetters(['article', 'comments']); // no generics needed any more | ||
fetch(props.articleId); // dispatch the "fetch" action | ||
return { | ||
// both are computed compositions for to the store | ||
article, | ||
comments | ||
} | ||
} | ||
} | ||
``` | ||
### Advanced Usage Example | ||
@@ -130,0 +160,0 @@ |
@@ -9,2 +9,6 @@ import {Store} from 'vuex/types'; | ||
export function useStore<TState = any>() { | ||
return getStoreFromInstance() as Store<TState> | ||
} | ||
export function useState<TState = any>(storeOrMap: Store<TState> | KnownKeys<TState>[], map?: KnownKeys<TState>[]): RefTypes<TState> { | ||
@@ -11,0 +15,0 @@ let store = storeOrMap; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36454
508
266