UNPKG

@hanxx/vue-hooks

Version:
36 lines (35 loc) 1.79 kB
import Vue from 'vue'; import { Dispatch, Commit } from 'vuex'; import { Ref } from '@vue/composition-api'; declare type Dictionary<T> = { [key: string]: T; }; declare type Computed = Ref<any>; declare type MutationMethod = (...args: any[]) => void; declare type ActionMethod = (...args: any[]) => Promise<any>; declare type CustomVue = Vue & Dictionary<any>; interface Mapper<R> { (map: string[]): Dictionary<R>; (map: Dictionary<string>): Dictionary<R>; } interface MapperWithNamespace<R> { (namespace: string, map: string[]): Dictionary<R>; (namespace: string, map: Dictionary<string>): Dictionary<R>; } interface FunctionMapper<F, R> { (map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any>): Dictionary<R>; } interface FunctionMapperWithNamespace<F, R> { (namespace: string, map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any>): Dictionary<R>; } interface MapperForState { <S>(map: Dictionary<(this: CustomVue, state: S, getters: any) => any>): Dictionary<Computed>; } interface MapperForStateWithNamespace { <S>(namespace: string, map: Dictionary<(this: CustomVue, state: S, getters: any) => any>): Dictionary<Computed>; } export declare type useState = Mapper<Computed> & MapperWithNamespace<Computed> & MapperForState & MapperForStateWithNamespace; export declare type useGetters = Mapper<Computed> & MapperWithNamespace<Computed>; export declare type useMutations = Mapper<MutationMethod> & MapperWithNamespace<MutationMethod> & FunctionMapper<Commit, MutationMethod> & FunctionMapperWithNamespace<Commit, MutationMethod>; export declare type useActions = Mapper<ActionMethod> & MapperWithNamespace<ActionMethod> & FunctionMapper<Dispatch, ActionMethod> & FunctionMapperWithNamespace<Dispatch, ActionMethod>; export {};