File tree Expand file tree Collapse file tree 2 files changed +3
-19
lines changed
packages/node_modules/overmind/src Expand file tree Collapse file tree 2 files changed +3
-19
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,9 @@ import {
5959 getActionPaths ,
6060 getFunctionName ,
6161 isPromise ,
62- runMutation ,
6362 processState ,
6463} from './utils'
65-
64+ import { rehydrate } from './rehydrate'
6665export * from './types'
6766
6867export { createOperator , createMutationOperator , ResolveState , ResolveActions }
@@ -952,9 +951,10 @@ export class Overmind<ThisConfig extends IConfiguration>
952951 this . actions = this . getActions ( configuration . actions )
953952 this . effects = configuration . effects || { }
954953
954+ // We do one at a time as they might error due to changed state structure
955955 this . reydrateMutationsForHotReloading . forEach ( ( mutation ) => {
956956 try {
957- runMutation ( this . state , mutation )
957+ rehydrate ( this . state as any , [ mutation ] )
958958 } catch ( error ) {
959959 // No worries, structure changed and we do not want to mutate anyways
960960 }
Original file line number Diff line number Diff line change @@ -90,22 +90,6 @@ export function deepCopy(obj) {
9090 return obj
9191}
9292
93- export const runMutation = ( state : any , mutation : IMutation ) => {
94- const pathArray = mutation . path . split ( mutation . delimiter )
95- const key = pathArray . pop ( ) as string
96- const target = pathArray . reduce ( ( current , pathKey ) => current [ pathKey ] . __CLASS__ ? current [ pathKey ] . value : current [ pathKey ] , state )
97-
98- switch ( mutation . method ) {
99- case 'set' :
100- target [ key ] = mutation . args [ 0 ]
101- break
102- case 'unset' :
103- delete target [ key ]
104- break
105- default :
106- target [ key ] [ mutation . method ] ( ...mutation . args )
107- }
108- }
10993
11094
11195export function getActionPaths ( actions = { } , currentPath : string [ ] = [ ] ) {
You can’t perform that action at this time.
0 commit comments