diff --git a/types/index.d.ts b/types/index.d.ts index 82593d048..ef2a6a45b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -18,8 +18,8 @@ export declare class Store { dispatch: Dispatch; commit: Commit; - subscribe

(fn: (mutation: P, state: S) => any): () => void; - subscribeAction

(fn: SubscribeActionOptions): () => void; + subscribe

(fn: (mutation: P, state: S) => any, options?: SubscribeOptions): () => void; + subscribeAction

(fn: SubscribeActionOptions, options?: SubscribeOptions): () => void; watch(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void; registerModule(path: string, module: Module, options?: ModuleOptions): void; @@ -72,6 +72,10 @@ export interface ActionPayload extends Payload { payload: any; } +export interface SubscribeOptions { + prepend?: boolean +} + export type ActionSubscriber = (action: P, state: S) => any; export interface ActionSubscribersObject { diff --git a/types/test/index.ts b/types/test/index.ts index 288a5737f..8caac47cd 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -39,6 +39,8 @@ namespace StoreInstance { state.value; }); + store.subscribe(() => {}, { prepend: true }); + store.subscribeAction((action, state) => { action.type; action.payload; @@ -74,6 +76,8 @@ namespace StoreInstance { } }); + store.subscribeAction({}, { prepend: true }); + store.replaceState({ value: 10 }); }