1
0
Эх сурвалжийг харах

update type definition for subscribe

Evan You 8 жил өмнө
parent
commit
55b4415087

+ 1 - 4
types/index.d.ts

@@ -16,10 +16,7 @@ declare namespace Vuex {
       modules?: ModuleTree;
     }): void;
 
-    on(event: string, cb: (...args: any[]) => void): void;
-    once(event: string, cb: (...args: any[]) => void): void;
-    off(event?: string, cb?: (...args: any[]) => void): void;
-    emit(event: string, ...args: any[]): void;
+    subscribe(cb: (mutation: MutationObject<any>, state: S) => void): () => void;
   }
 
   function install(Vue: vuejs.VueStatic): void;

+ 2 - 9
types/test/index.ts

@@ -191,21 +191,14 @@ namespace TestHotUpdate {
   });
 }
 
-namespace TestEvents {
+namespace TestSubscribe {
   const store = createStore();
 
   const handler = (mutation: Vuex.MutationObject<any>, state: ISimpleState) => {
     state.count += 1;
   };
 
-  store.on('mutation', handler);
-  store.once('mutation', handler);
-
-  store.off();
-  store.off('mutation');
-  store.off('mutation', handler);
-
-  store.emit('some-event', 1, 'a', []);
+  store.subscribe(handler);
 }
 
 namespace TestLogger {