1 | import _Vue, { WatchOptions } from "vue";
|
2 |
|
3 |
|
4 | import "./vue";
|
5 |
|
6 | import { mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers } from "./helpers";
|
7 |
|
8 | export * from "./helpers";
|
9 |
|
10 | export declare class Store<S> {
|
11 | constructor(options: StoreOptions<S>);
|
12 |
|
13 | readonly state: S;
|
14 | readonly getters: any;
|
15 |
|
16 | replaceState(state: S): void;
|
17 |
|
18 | dispatch: Dispatch;
|
19 | commit: Commit;
|
20 |
|
21 | subscribe<P extends MutationPayload>(fn: (mutation: P, state: S) => any): () => void;
|
22 | subscribeAction<P extends ActionPayload>(fn: SubscribeActionOptions<P, S>): () => void;
|
23 | watch<T>(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;
|
24 |
|
25 | registerModule<T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
|
26 | registerModule<T>(path: string[], module: Module<T, S>, options?: ModuleOptions): void;
|
27 |
|
28 | unregisterModule(path: string): void;
|
29 | unregisterModule(path: string[]): void;
|
30 |
|
31 | hotUpdate(options: {
|
32 | actions?: ActionTree<S, S>;
|
33 | mutations?: MutationTree<S>;
|
34 | getters?: GetterTree<S, S>;
|
35 | modules?: ModuleTree<S>;
|
36 | }): void;
|
37 | }
|
38 |
|
39 | export declare function install(Vue: typeof _Vue): void;
|
40 |
|
41 | export interface Dispatch {
|
42 | (type: string, payload?: any, options?: DispatchOptions): Promise<any>;
|
43 | <P extends Payload>(payloadWithType: P, options?: DispatchOptions): Promise<any>;
|
44 | }
|
45 |
|
46 | export interface Commit {
|
47 | (type: string, payload?: any, options?: CommitOptions): void;
|
48 | <P extends Payload>(payloadWithType: P, options?: CommitOptions): void;
|
49 | }
|
50 |
|
51 | export interface ActionContext<S, R> {
|
52 | dispatch: Dispatch;
|
53 | commit: Commit;
|
54 | state: S;
|
55 | getters: any;
|
56 | rootState: R;
|
57 | rootGetters: any;
|
58 | }
|
59 |
|
60 | export interface Payload {
|
61 | type: string;
|
62 | }
|
63 |
|
64 | export interface MutationPayload extends Payload {
|
65 | payload: any;
|
66 | }
|
67 |
|
68 | export interface ActionPayload extends Payload {
|
69 | payload: any;
|
70 | }
|
71 |
|
72 | export type ActionSubscriber<P, S> = (action: P, state: S) => any;
|
73 |
|
74 | export interface ActionSubscribersObject<P, S> {
|
75 | before?: ActionSubscriber<P, S>;
|
76 | after?: ActionSubscriber<P, S>;
|
77 | }
|
78 |
|
79 | export type SubscribeActionOptions<P, S> = ActionSubscriber<P, S> | ActionSubscribersObject<P, S>;
|
80 |
|
81 | export interface DispatchOptions {
|
82 | root?: boolean;
|
83 | }
|
84 |
|
85 | export interface CommitOptions {
|
86 | silent?: boolean;
|
87 | root?: boolean;
|
88 | }
|
89 |
|
90 | export interface StoreOptions<S> {
|
91 | state?: S | (() => S);
|
92 | getters?: GetterTree<S, S>;
|
93 | actions?: ActionTree<S, S>;
|
94 | mutations?: MutationTree<S>;
|
95 | modules?: ModuleTree<S>;
|
96 | plugins?: Plugin<S>[];
|
97 | strict?: boolean;
|
98 | }
|
99 |
|
100 | export type ActionHandler<S, R> = (this: Store<R>, injectee: ActionContext<S, R>, payload?: any) => any;
|
101 | export interface ActionObject<S, R> {
|
102 | root?: boolean;
|
103 | handler: ActionHandler<S, R>;
|
104 | }
|
105 |
|
106 | export type Getter<S, R> = (state: S, getters: any, rootState: R, rootGetters: any) => any;
|
107 | export type Action<S, R> = ActionHandler<S, R> | ActionObject<S, R>;
|
108 | export type Mutation<S> = (state: S, payload?: any) => any;
|
109 | export type Plugin<S> = (store: Store<S>) => any;
|
110 |
|
111 | export interface Module<S, R> {
|
112 | namespaced?: boolean;
|
113 | state?: S | (() => S);
|
114 | getters?: GetterTree<S, R>;
|
115 | actions?: ActionTree<S, R>;
|
116 | mutations?: MutationTree<S>;
|
117 | modules?: ModuleTree<R>;
|
118 | }
|
119 |
|
120 | export interface ModuleOptions {
|
121 | preserveState?: boolean;
|
122 | }
|
123 |
|
124 | export interface GetterTree<S, R> {
|
125 | [key: string]: Getter<S, R>;
|
126 | }
|
127 |
|
128 | export interface ActionTree<S, R> {
|
129 | [key: string]: Action<S, R>;
|
130 | }
|
131 |
|
132 | export interface MutationTree<S> {
|
133 | [key: string]: Mutation<S>;
|
134 | }
|
135 |
|
136 | export interface ModuleTree<R> {
|
137 | [key: string]: Module<any, R>;
|
138 | }
|
139 |
|
140 | declare const _default: {
|
141 | Store: typeof Store;
|
142 | install: typeof install;
|
143 | mapState: typeof mapState,
|
144 | mapMutations: typeof mapMutations,
|
145 | mapGetters: typeof mapGetters,
|
146 | mapActions: typeof mapActions,
|
147 | createNamespacedHelpers: typeof createNamespacedHelpers,
|
148 | };
|
149 | export default _default;
|
150 |
|
\ | No newline at end of file |