Ver código fonte

Merge remote-tracking branch 'origin/dev' into 4.0

ktsn 5 anos atrás
pai
commit
2e71da699b
3 arquivos alterados com 26 adições e 2 exclusões
  1. 16 0
      CHANGELOG.md
  2. 6 2
      types/index.d.ts
  3. 4 0
      types/test/index.ts

+ 16 - 0
CHANGELOG.md

@@ -1,3 +1,19 @@
+# [3.3.0](https://github.com/vuejs/vuex/compare/v3.2.0...v3.3.0) (2020-04-25)
+
+
+### Bug Fixes
+
+* Prepend devtool handler ([#1358](https://github.com/vuejs/vuex/issues/1358)) ([a39d076](https://github.com/vuejs/vuex/commit/a39d0767e4041cdd5cf8050774106c01d39024e0)), closes [vuejs/vue-devtools#678](https://github.com/vuejs/vue-devtools/issues/678)
+* **types:** Add `devtools` to store options type ([#1478](https://github.com/vuejs/vuex/issues/1478)) ([38c11dc](https://github.com/vuejs/vuex/commit/38c11dcbaea7d7e661a1623cabb5aef7c6e47ba7))
+
+
+### Features
+
+* Add `prepend` option for `subscribe` and `subscribeAction` ([#1358](https://github.com/vuejs/vuex/issues/1358)) ([a39d076](https://github.com/vuejs/vuex/commit/a39d0767e4041cdd5cf8050774106c01d39024e0))
+* **logger:** `createLogger` can optionally log actions ([#987](https://github.com/vuejs/vuex/issues/987)) ([18be128](https://github.com/vuejs/vuex/commit/18be128ad933d1fca6da05c060f7664ce0c819ae))
+
+
+
 # [3.2.0](https://github.com/vuejs/vuex/compare/v3.1.3...v3.2.0) (2020-04-19)
 
 

+ 6 - 2
types/index.d.ts

@@ -20,8 +20,8 @@ export declare class Store<S> {
   dispatch: Dispatch;
   commit: Commit;
 
-  subscribe<P extends MutationPayload>(fn: (mutation: P, state: S) => any): () => void;
-  subscribeAction<P extends ActionPayload>(fn: SubscribeActionOptions<P, S>): () => void;
+  subscribe<P extends MutationPayload>(fn: (mutation: P, state: S) => any, options?: SubscribeOptions): () => void;
+  subscribeAction<P extends ActionPayload>(fn: SubscribeActionOptions<P, S>, options?: SubscribeOptions): () => void;
   watch<T>(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;
 
   registerModule<T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
@@ -74,6 +74,10 @@ export interface ActionPayload extends Payload {
   payload: any;
 }
 
+export interface SubscribeOptions {
+  prepend?: boolean
+}
+
 export type ActionSubscriber<P, S> = (action: P, state: S) => any;
 
 export interface ActionSubscribersObject<P, S> {

+ 4 - 0
types/test/index.ts

@@ -36,6 +36,8 @@ namespace StoreInstance {
     state.value;
   });
 
+  store.subscribe(() => {}, { prepend: true });
+
   store.subscribeAction((action, state) => {
     action.type;
     action.payload;
@@ -71,6 +73,8 @@ namespace StoreInstance {
     }
   });
 
+  store.subscribeAction({}, { prepend: true });
+
   store.replaceState({ value: 10 });
 }