Browse Source

update type definition for subscribe

Evan You 8 years ago
parent
commit
55b4415087
2 changed files with 3 additions and 13 deletions
  1. 1 4
      types/index.d.ts
  2. 2 9
      types/test/index.ts

+ 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 {