Skip to content

Commit df2411f

Browse files
timdeschryverbrandonroberts
authored andcommitted
fix(StoreDevtools): pass timestamp to actions
1 parent 32df3f0 commit df2411f

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

modules/store-devtools/spec/extension.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('DevtoolsExtension', () => {
170170
const SANITIZED_COUNTER = 42;
171171

172172
function createPerformAction() {
173-
return new PerformAction({ type: UNSANITIZED_TOKEN });
173+
return new PerformAction({ type: UNSANITIZED_TOKEN }, +Date.now());
174174
}
175175

176176
function testActionSanitizer(action: Action, id: number) {

modules/store-devtools/src/actions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const IMPORT_STATE = 'IMPORT_STATE';
1414
export class PerformAction implements Action {
1515
readonly type = PERFORM_ACTION;
1616

17-
constructor(public action: Action, public timestamp?: number) {
17+
constructor(public action: Action, public timestamp: number) {
1818
if (typeof action.type === 'undefined') {
1919
throw new Error(
2020
'Actions may not have an undefined "type" property. ' +
@@ -27,19 +27,19 @@ export class PerformAction implements Action {
2727
export class Reset implements Action {
2828
readonly type = RESET;
2929

30-
constructor(public timestamp?: number) {}
30+
constructor(public timestamp: number) {}
3131
}
3232

3333
export class Rollback implements Action {
3434
readonly type = ROLLBACK;
3535

36-
constructor(public timestamp?: number) {}
36+
constructor(public timestamp: number) {}
3737
}
3838

3939
export class Commit implements Action {
4040
readonly type = COMMIT;
4141

42-
constructor(public timestamp?: number) {}
42+
constructor(public timestamp: number) {}
4343
}
4444

4545
export class Sweep implements Action {

modules/store-devtools/src/devtools.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,19 @@ export class StoreDevtools implements Observer<any> {
119119
complete() {}
120120

121121
performAction(action: any) {
122-
this.dispatch(new Actions.PerformAction(action));
122+
this.dispatch(new Actions.PerformAction(action, +Date.now()));
123123
}
124124

125125
reset() {
126-
this.dispatch(new Actions.Reset());
126+
this.dispatch(new Actions.Reset(+Date.now()));
127127
}
128128

129129
rollback() {
130-
this.dispatch(new Actions.Rollback());
130+
this.dispatch(new Actions.Rollback(+Date.now()));
131131
}
132132

133133
commit() {
134-
this.dispatch(new Actions.Commit());
134+
this.dispatch(new Actions.Commit(+Date.now()));
135135
}
136136

137137
sweep() {

modules/store-devtools/src/reducer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ export function liftReducerWith(
392392

393393
// Add a new action to only recompute state
394394
const actionId = nextActionId++;
395-
actionsById[actionId] = new PerformAction(liftedAction);
395+
actionsById[actionId] = new PerformAction(liftedAction, +Date.now());
396396
stagedActionIds = [...stagedActionIds, actionId];
397397

398398
minInvalidatedStateIndex = stagedActionIds.length - 1;

modules/store-devtools/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function unliftAction(liftedState: LiftedState): LiftedAction {
3232
* Lifts an app's action into an action on the lifted store.
3333
*/
3434
export function liftAction(action: Action) {
35-
return new Actions.PerformAction(action);
35+
return new Actions.PerformAction(action, +Date.now());
3636
}
3737

3838
/**

0 commit comments

Comments
 (0)