Skip to content

Commit ca64c3f

Browse files
snaptopixelktsn
authored andcommitted
Add subscribeAction in index.d.ts fixes #1066 (#1067)
1 parent 59c39b6 commit ca64c3f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export declare class Store<S> {
1717
commit: Commit;
1818

1919
subscribe<P extends MutationPayload>(fn: (mutation: P, state: S) => any): () => void;
20+
subscribeAction<P extends ActionPayload>(fn: (action: P, state: S) => any): () => void;
2021
watch<T>(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;
2122

2223
registerModule<T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
@@ -62,6 +63,10 @@ export interface MutationPayload extends Payload {
6263
payload: any;
6364
}
6465

66+
export interface ActionPayload extends Payload {
67+
payload: any;
68+
}
69+
6570
export interface DispatchOptions {
6671
root?: boolean;
6772
}

types/test/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ namespace StoreInstance {
3939
state.value;
4040
});
4141

42+
store.subscribeAction((mutation, state) => {
43+
mutation.type;
44+
mutation.payload;
45+
state.value;
46+
});
47+
4248
store.replaceState({ value: 10 });
4349
}
4450

0 commit comments

Comments
 (0)