@@ -4,12 +4,7 @@ import { ActionContext, ActionTree, GetterTree, Module, MutationTree, Store } fr
4
4
const useRootNamespace = { root : true }
5
5
6
6
export type MutationHandler < S , P > = ( state : S , payload : P ) => void
7
- // export type PayloadlessMutationHandler<S> = (state: S) => void
8
-
9
7
export type ActionHandler < S , R , P , T > = ( context : BareActionContext < S , R > , payload : P ) => Promise < T >
10
- // export type PayloadlessActionHandler<S, R, T> = (context: BareActionContext<S, R>) => Promise<T>
11
- // export type VoidActionHandler<S, R, P> = (context: BareActionContext<S, R>, payload: P) => void
12
- // export type VoidPayloadlessActionHandler<S, R> = (context: BareActionContext<S, R>) => void
13
8
export type GetterHandler < S , R , T > = ( state : S , rootState : R ) => T
14
9
15
10
export interface BareActionContext < S , R >
@@ -34,19 +29,25 @@ export class ModuleBuilder<S, R> {
34
29
35
30
commit < P > ( handler : MutationHandler < S , void > ) : ( ) => void
36
31
commit < P > ( handler : MutationHandler < S , P > ) : ( payload : P ) => void
37
- commit < P > ( handler : MutationHandler < S , P > )
32
+ commit < P > ( handler : MutationHandler < S , void > , name : string ) : ( ) => void
33
+ commit < P > ( handler : MutationHandler < S , P > , name : string ) : ( payload : P ) => void
34
+ commit < P > ( handler : MutationHandler < S , P > , name ?: string )
38
35
{
39
- const key = qualifyKey ( handler , this . namespace )
36
+ const key = qualifyKey ( handler , this . namespace , name )
40
37
return ( ( payload : P ) => this . store . commit ( key , payload , useRootNamespace ) ) as any
41
38
}
42
39
43
40
dispatch < P , T > ( handler : ActionHandler < S , R , void , void > ) : ( ) => Promise < void >
44
41
dispatch < P , T > ( handler : ActionHandler < S , R , P , void > ) : ( payload : P ) => Promise < void >
45
42
dispatch < P , T > ( handler : ActionHandler < S , R , void , T > ) : ( ) => Promise < T >
46
43
dispatch < P , T > ( handler : ActionHandler < S , R , P , T > ) : ( payload : P ) => Promise < T >
47
- dispatch < P , T > ( handler : any ) : any
44
+ dispatch < P , T > ( handler : ActionHandler < S , R , void , void > , name : string ) : ( ) => Promise < void >
45
+ dispatch < P , T > ( handler : ActionHandler < S , R , P , void > , name : string ) : ( payload : P ) => Promise < void >
46
+ dispatch < P , T > ( handler : ActionHandler < S , R , void , T > , name : string ) : ( ) => Promise < T >
47
+ dispatch < P , T > ( handler : ActionHandler < S , R , P , T > , name : string ) : ( payload : P ) => Promise < T >
48
+ dispatch < P , T > ( handler : any , name ?: string ) : any
48
49
{
49
- const key = qualifyKey ( handler , this . namespace )
50
+ const key = qualifyKey ( handler , this . namespace , name )
50
51
return ( payload : P ) => this . store . dispatch ( key , payload , useRootNamespace )
51
52
}
52
53
0 commit comments