8000 update type definition for subscribe · padcom/vuejs.org@6c669a5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c669a5

Browse files
committed
update type definition for subscribe
1 parent bc5447e commit 6c669a5

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

types/index.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ declare namespace Vuex {
1616
modules?: ModuleTree;
1717
}): void;
1818

19-
on(event: string, cb: (...args: any[]) => void): void;
20-
once(event: string, cb: (...args: any[]) => void): void;
21-
off(event?: string, cb?: (...args: any[]) => void): void;
22-
emit(event: string, ...args: any[]): void;
19+
subscribe(cb: (mutation: MutationObject<any>, state: S) => void): () => void;
2320
}
2421

2522
function install(Vue: vuejs.VueStatic): void;

types/test/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,14 @@ namespace TestHotUpdate {
169169
});
170170
}
171171

172-
namespace TestEvents {
172+
namespace TestSubscribe {
173173
const store = createStore();
174174

175175
const handler = (mutation: Vuex.MutationObject<any>, state: ISimpleState) => {
176176
state.count += 1;
177177
};
178178

179-
store.on('mutation', handler);
180-
store.once('mutation', handler);
181-
182-
store.off();
183-
store.off('mutation');
184-
store.off('mutation', handler);
185-
186-
store.emit('some-event', 1, 'a', []);
179+
store.subscribe(handler);
187180
}
188181

189182
namespace TestLogger {

0 commit comments

Comments
 (0)
0