Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(StoreDevtools): pass timestamp to actions
  • Loading branch information
timdeschryver authored and brandonroberts committed Mar 30, 2018
1 parent 32df3f0 commit df2411f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/store-devtools/spec/extension.spec.ts
Expand Up @@ -170,7 +170,7 @@ describe('DevtoolsExtension', () => {
const SANITIZED_COUNTER = 42;

function createPerformAction() {
return new PerformAction({ type: UNSANITIZED_TOKEN });
return new PerformAction({ type: UNSANITIZED_TOKEN }, +Date.now());
}

function testActionSanitizer(action: Action, id: number) {
Expand Down
8 changes: 4 additions & 4 deletions modules/store-devtools/src/actions.ts
Expand Up @@ -14,7 +14,7 @@ export const IMPORT_STATE = 'IMPORT_STATE';
export class PerformAction implements Action {
readonly type = PERFORM_ACTION;

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

constructor(public timestamp?: number) {}
constructor(public timestamp: number) {}
}

export class Rollback implements Action {
readonly type = ROLLBACK;

constructor(public timestamp?: number) {}
constructor(public timestamp: number) {}
}

export class Commit implements Action {
readonly type = COMMIT;

constructor(public timestamp?: number) {}
constructor(public timestamp: number) {}
}

export class Sweep implements Action {
Expand Down
8 changes: 4 additions & 4 deletions modules/store-devtools/src/devtools.ts
Expand Up @@ -119,19 +119,19 @@ export class StoreDevtools implements Observer<any> {
complete() {}

performAction(action: any) {
this.dispatch(new Actions.PerformAction(action));
this.dispatch(new Actions.PerformAction(action, +Date.now()));
}

reset() {
this.dispatch(new Actions.Reset());
this.dispatch(new Actions.Reset(+Date.now()));
}

rollback() {
this.dispatch(new Actions.Rollback());
this.dispatch(new Actions.Rollback(+Date.now()));
}

commit() {
this.dispatch(new Actions.Commit());
this.dispatch(new Actions.Commit(+Date.now()));
}

sweep() {
Expand Down
2 changes: 1 addition & 1 deletion modules/store-devtools/src/reducer.ts
Expand Up @@ -392,7 +392,7 @@ export function liftReducerWith(

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

minInvalidatedStateIndex = stagedActionIds.length - 1;
Expand Down
2 changes: 1 addition & 1 deletion modules/store-devtools/src/utils.ts
Expand Up @@ -32,7 +32,7 @@ export function unliftAction(liftedState: LiftedState): LiftedAction {
* Lifts an app's action into an action on the lifted store.
*/
export function liftAction(action: Action) {
return new Actions.PerformAction(action);
return new Actions.PerformAction(action, +Date.now());
}

/**
Expand Down

0 comments on commit df2411f

Please sign in to comment.