@@ -12,7 +12,8 @@ export const ActionTypes = {
12
12
TOGGLE_ACTION : 'TOGGLE_ACTION' ,
13
13
SET_ACTIONS_ACTIVE : 'SET_ACTIONS_ACTIVE' ,
14
14
JUMP_TO_STATE : 'JUMP_TO_STATE' ,
15
- IMPORT_STATE : 'IMPORT_STATE'
15
+ IMPORT_STATE : 'IMPORT_STATE' ,
16
+ LOCK_CHANGES : 'LOCK_CHANGES'
16
17
} ;
17
18
18
19
/**
@@ -67,6 +68,10 @@ export const ActionCreators = {
67
68
68
69
importState ( nextLiftedState , noRecompute ) {
69
70
return { type : ActionTypes . IMPORT_STATE , nextLiftedState, noRecompute } ;
71
+ } ,
72
+
73
+ lockChanges ( status ) {
74
+ return { type : ActionTypes . LOCK_CHANGES , status } ;
70
75
}
71
76
} ;
72
77
@@ -175,7 +180,8 @@ export function liftReducerWith(reducer, initialCommittedState, monitorReducer,
175
180
skippedActionIds : [ ] ,
176
181
committedState : initialCommittedState ,
177
182
currentStateIndex : 0 ,
178
- computedStates : [ ]
183
+ computedStates : [ ] ,
184
+ dropNewActions : false
179
185
} ;
180
186
181
187
/**
@@ -190,7 +196,8 @@ export function liftReducerWith(reducer, initialCommittedState, monitorReducer,
190
196
skippedActionIds,
191
197
committedState,
192
198
currentStateIndex,
193
- computedStates
199
+ computedStates,
200
+ dropNewActions
194
201
} = liftedState || initialLiftedState ;
195
202
196
203
if ( ! liftedState ) {
@@ -309,6 +316,10 @@ export function liftReducerWith(reducer, initialCommittedState, monitorReducer,
309
316
break ;
310
317
}
311
318
case ActionTypes . PERFORM_ACTION : {
319
+ if ( dropNewActions ) {
320
+ return liftedState || initialLiftedState ;
321
+ }
322
+
312
323
// Auto-commit as new actions come in.
313
324
if ( options . maxAge && stagedActionIds . length === options . maxAge ) {
314
325
commitExcessActions ( 1 ) ;
@@ -363,6 +374,11 @@ export function liftReducerWith(reducer, initialCommittedState, monitorReducer,
363
374
364
375
break ;
365
376
}
377
+ case ActionTypes . LOCK_CHANGES : {
378
+ dropNewActions = liftedAction . status ;
379
+ minInvalidatedStateIndex = Infinity ;
380
+ break ;
381
+ }
366
382
case '@@redux/INIT' : {
367
383
// Always recompute states on hot reload and init.
368
384
minInvalidatedStateIndex = 0 ;
@@ -415,7 +431,8 @@ export function liftReducerWith(reducer, initialCommittedState, monitorReducer,
415
431
skippedActionIds,
416
432
committedState,
417
433
currentStateIndex,
418
- computedStates
434
+ computedStates,
435
+ dropNewActions
419
436
} ;
420
437
} ;
421
438
}
0 commit comments