Skip to content

Commit 55b4415

Browse files
committed
update type definition for subscribe
1 parent 031ddb5 commit 55b4415

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

types/index.d.ts

+1-4
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

+2-9
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,14 @@ namespace TestHotUpdate {
191191
});
192192
}
193193

194-
namespace TestEvents {
194+
namespace TestSubscribe {
195195
const store = createStore();
196196

197197
const handler = (mutation: Vuex.MutationObject<any>, state: ISimpleState) => {
198198
state.count += 1;
199199
};
200200

201-
store.on('mutation', handler);
202-
store.once('mutation', handler);
203-
204-
store.off();
205-
store.off('mutation');
206-
store.off('mutation', handler);
207-
208-
store.emit('some-event', 1, 'a', []);
201+
store.subscribe(handler);
209202
}
210203

211204
namespace TestLogger {

0 commit comments

Comments
 (0)