@@ -25,7 +25,7 @@ import {
2525 Options ,
2626 ResolveActions ,
2727 SSRMode ,
28- TestMode
28+ TestMode ,
2929} from './internalTypes'
3030import {
3131 createContext ,
@@ -59,7 +59,7 @@ import {
5959 getChangeMutations ,
6060 getFunctionName ,
6161 isPromise ,
62- processState
62+ processState ,
6363} from './utils'
6464
6565export * from './types'
@@ -72,7 +72,9 @@ export { SERIALIZE, rehydrate } from './rehydrate'
7272
7373export { Statemachine , statemachine } from './statemachine'
7474
75- export const derived = < S extends object , R extends object , O > ( cb : ( state : S , rootState : R ) => O ) : O => {
75+ export const derived = < S extends object , R extends object , O > (
76+ cb : ( state : S , rootState : R ) => O
77+ ) : O => {
7678 cb [ IS_DERIVED_CONSTRUCTOR ] = true
7779 return cb as any
7880}
@@ -85,7 +87,7 @@ export interface Config {}
8587
8688export interface Context extends IContext < Config > { }
8789
88- export type RootState = Context [ " state" ]
90+ export type RootState = Context [ ' state' ]
8991
9092export interface Action < Value = void , ReturnValue = void >
9193 extends IAction < Config , Value , ReturnValue > { }
@@ -250,12 +252,11 @@ export class Overmind<ThisConfig extends IConfiguration>
250252 this . eventHub = eventHub as EventEmitter < Events >
251253 this . mode = mode
252254
253-
254255 /*
255256 Expose the created actions
256257 */
257258 this . actions = this . getActions ( configuration . actions )
258-
259+
259260 if ( mode . mode === MODE_SSR ) {
260261 return
261262 }
@@ -333,9 +334,14 @@ export class Overmind<ThisConfig extends IConfiguration>
333334 nextTick = setTimeout ( flushTree , 0 )
334335 } )
335336 } else if ( mode . mode === MODE_DEFAULT || mode . mode === MODE_TEST ) {
336- if ( process . env . NODE_ENV === 'test' || ( this . devtools && options . hotReloading !== false ) ) {
337+ if (
338+ process . env . NODE_ENV === 'test' ||
339+ ( this . devtools && options . hotReloading !== false )
340+ ) {
337341 eventHub . on ( EventType . MUTATIONS , ( execution ) => {
338- this . reydrateMutationsForHotReloading = this . reydrateMutationsForHotReloading . concat ( execution . mutations )
342+ this . reydrateMutationsForHotReloading = this . reydrateMutationsForHotReloading . concat (
343+ execution . mutations
344+ )
339345 } )
340346 }
341347 eventHub . on ( EventType . OPERATOR_ASYNC , ( execution ) => {
@@ -395,6 +401,7 @@ export class Overmind<ThisConfig extends IConfiguration>
395401 this . getState ( configuration ) as any ,
396402 {
397403 devmode,
404+ ssr : this . mode . mode === MODE_SSR ,
398405 delimiter : this . delimiter ,
399406 onSetFunction : ( tree , path , target , prop , func ) => {
400407 if ( func [ IS_DERIVED_CONSTRUCTOR ] ) {
@@ -407,23 +414,33 @@ export class Overmind<ThisConfig extends IConfiguration>
407414 let func = target [ prop ]
408415
409416 if ( func [ IS_DERIVED ] ) {
410- return func ( eventHub , tree , proxyStateTree , path . split ( this . delimiter ) )
417+ return func (
418+ eventHub ,
419+ tree ,
420+ proxyStateTree ,
421+ path . split ( this . delimiter )
422+ )
411423 }
412424
413425 if ( func [ IS_DERIVED_CONSTRUCTOR ] ) {
414426 const derived = new Derived ( func ) as any
415427 target [ prop ] = derived
416428
417- return derived ( eventHub , tree , proxyStateTree , path . split ( this . delimiter ) )
429+ return derived (
430+ eventHub ,
431+ tree ,
432+ proxyStateTree ,
433+ path . split ( this . delimiter )
434+ )
418435 }
419436
420437 return func
421- } ,
438+ } ,
422439 onGetter : devmode
423440 ? ( path , value ) => {
424441 this . eventHub . emitAsync ( EventType . GETTER , {
425442 path,
426- value
443+ value,
427444 } )
428445 }
429446 : undefined ,
@@ -542,7 +559,7 @@ export class Overmind<ThisConfig extends IConfiguration>
542559 const execution = this . createExecution ( name , action , boundExecution )
543560 this . eventHub . emit ( EventType . ACTION_START , {
544561 ...execution ,
545- value
562+ value,
546563 } )
547564
548565 if ( action [ IS_OPERATOR ] ) {
@@ -593,7 +610,7 @@ export class Overmind<ThisConfig extends IConfiguration>
593610 }
594611 this . eventHub . emit ( EventType . ACTION_START , {
595612 ...execution ,
596- value
613+ value,
597614 } )
598615 this . eventHub . emit ( EventType . OPERATOR_START , execution )
599616
@@ -703,7 +720,6 @@ export class Overmind<ThisConfig extends IConfiguration>
703720 return actionFunc
704721 }
705722 private trackEffects ( effects = { } , execution ) {
706-
707723 if ( process . env . NODE_ENV === 'production' ) {
708724 return effects
709725 }
@@ -836,7 +852,9 @@ export class Overmind<ThisConfig extends IConfiguration>
836852 // We want to trigger property access when setting objects and arrays, as any derived set would
837853 // then trigger and update the devtools
838854 data . mutations . forEach ( ( mutation ) => {
839- const value = mutation . path . split ( this . delimiter ) . reduce ( ( aggr , key ) => aggr [ key ] , this . proxyStateTree . state )
855+ const value = mutation . path
856+ . split ( this . delimiter )
857+ . reduce ( ( aggr , key ) => aggr [ key ] , this . proxyStateTree . state )
840858 if ( isPlainObject ( value ) ) {
841859 Object . keys ( value ) . forEach ( ( key ) => value [ key ] )
842860 } else if ( Array . isArray ( value ) ) {
@@ -848,11 +866,13 @@ export class Overmind<ThisConfig extends IConfiguration>
848866 }
849867 } )
850868 }
851-
869+
852870 // Access the derived which will trigger calculation and devtools
853871 if ( eventType === EventType . DERIVED_DIRTY ) {
854- data . derivedPath
855- . reduce ( ( aggr , key ) => aggr [ key ] , this . proxyStateTree . state )
872+ data . derivedPath . reduce (
873+ ( aggr , key ) => aggr [ key ] ,
874+ this . proxyStateTree . state
875+ )
856876 }
857877 } ) ( EventType [ type ] )
858878 )
@@ -862,17 +882,15 @@ export class Overmind<ThisConfig extends IConfiguration>
862882 data : {
863883 state : this . proxyStateTree . state ,
864884 actions : getActionPaths ( actions ) ,
865- delimiter : this . delimiter
885+ delimiter : this . delimiter ,
866886 } ,
867887 } )
868888 this . devtools = devtools
869889 }
870890 private getState ( configuration : IConfiguration ) {
871891 let state = { }
872892 if ( configuration . state ) {
873- state = processState (
874- configuration . state ,
875- )
893+ state = processState ( configuration . state )
876894 }
877895
878896 return state
@@ -915,11 +933,8 @@ export class Overmind<ThisConfig extends IConfiguration>
915933
916934 return aggr [ key ]
917935 } , this . actions )
918- target [ name ] = this . createAction (
919- actionName ,
920- actions [ name ]
921- ) as any
922-
936+ target [ name ] = this . createAction ( actionName , actions [ name ] ) as any
937+
923938 target [ name ] . displayName = path . concat ( name ) . join ( '.' )
924939 }
925940 } else {
@@ -955,7 +970,11 @@ export class Overmind<ThisConfig extends IConfiguration>
955970 mutations . forEach ( ( mutation ) => {
956971 if ( mutation . path . startsWith ( path ) ) {
957972 updateCallback (
958- path ? path . split ( this . delimiter ) . reduce ( ( aggr , key ) => aggr [ key ] , this . state ) : this . state
973+ path
974+ ? path
975+ . split ( this . delimiter )
976+ . reduce ( ( aggr , key ) => aggr [ key ] , this . state )
977+ : this . state
959978 )
960979 }
961980 } )
@@ -993,7 +1012,10 @@ export class Overmind<ThisConfig extends IConfiguration>
9931012 return this . proxyStateTree . onFlush ( cb )
9941013 }
9951014 reconfigure ( configuration : IConfiguration ) {
996- const changeMutations = getChangeMutations ( this . originalConfiguration . state , configuration . state || { } )
1015+ const changeMutations = getChangeMutations (
1016+ this . originalConfiguration . state ,
1017+ configuration . state || { }
1018+ )
9971019
9981020 this . updateActions ( configuration . actions )
9991021 this . effects = configuration . effects || { }
0 commit comments