@@ -345,7 +345,7 @@ export class Overmind<ThisConfig extends IConfiguration>
345345 /*
346346 Expose the created actions
347347 */
348- this . actions = this . getActions ( configuration )
348+ this . actions = this . getActions ( configuration . actions )
349349
350350 if ( mode . mode === MODE_DEFAULT && configuration . onInitialize ) {
351351 const onInitialize = this . createAction (
@@ -781,51 +781,22 @@ export class Overmind<ThisConfig extends IConfiguration>
781781 return aggr
782782 } , { } )
783783 }
784- private getActions ( configuration : IConfiguration ) {
785- let actions = { }
786- if ( configuration . actions ) {
787- actions = configuration . actions
788- }
789-
790- const evaluatedActions = Object . keys ( actions ) . reduce ( ( aggr , name ) => {
784+ private getActions ( actions : any = { } , path : string [ ] = [ ] ) {
785+ return Object . keys ( actions ) . reduce ( ( aggr , name ) => {
791786 if ( typeof actions [ name ] === 'function' ) {
787+ const action = this . createAction ( name , actions [ name ] ) as any
788+
789+ action . displayName = path . concat ( name ) . join ( '.' )
790+
792791 return Object . assign ( aggr , {
793- [ name ] : this . createAction ( name , actions [ name ] ) ,
792+ [ name ] : action ,
794793 } )
795794 }
796795
797796 return Object . assign ( aggr , {
798- [ name ] : Object . keys ( actions [ name ] || { } ) . reduce (
799- ( aggr , subName ) =>
800- Object . assign (
801- aggr ,
802- typeof actions [ name ] [ subName ] === 'function'
803- ? {
804- [ subName ] : this . createAction (
805- subName ,
806- actions [ name ] [ subName ]
807- ) ,
808- }
809- : { }
810- ) ,
811- { }
812- ) ,
797+ [ name ] : this . getActions ( actions [ name ] , path . concat ( name ) ) ,
813798 } )
814799 } , { } ) as any
815-
816- if ( this . devtools ) {
817- Object . keys ( evaluatedActions ) . forEach ( ( key ) => {
818- if ( typeof evaluatedActions [ key ] === 'function' ) {
819- evaluatedActions [ key ] . displayName = key
820- } else {
821- Object . keys ( evaluatedActions [ key ] ) . forEach ( ( subKey ) => {
822- evaluatedActions [ key ] [ subKey ] . displayName = key + '.' + subKey
823- } )
824- }
825- } )
826- }
827-
828- return evaluatedActions
829800 }
830801 getTrackStateTree ( ) {
831802 return this . proxyStateTree . getTrackStateTree ( )
@@ -852,7 +823,7 @@ export class Overmind<ThisConfig extends IConfiguration>
852823 this . proxyStateTree . sourceState = this . getState ( mergedConfiguration )
853824 proxyStateTree . createTrackStateProxifier ( )
854825 this . state = this . proxyStateTree . state as any
855- this . actions = this . getActions ( mergedConfiguration )
826+ this . actions = this . getActions ( mergedConfiguration . actions )
856827 this . effects = mergedConfiguration . effects || { }
857828
858829 this . proxyStateTree . forceFlush ( )
0 commit comments