【问题标题】:Angular 2 - prevent NGRX store from saving previous eventsAngular 2 - 防止 NGRX 存储保存以前的事件
【发布时间】:2017-09-10 10:09:20
【问题描述】:

如何防止 ngrx 商店保存所有以前的事件?我有一个 USER_WAS_ACTIVE 操作,每次用户移动鼠标或其他东西时都会重置注销时间。我自然不希望大量的事件填满内存。

另外我想在一个用户注销时手动清除商店,所以下一个用户不能只打开 redux devtools 并查看前一个用户对应用程序做了什么。

【问题讨论】:

  • 商店不存储事件;它存储由处理动作(事件)的化简器组成的状态。如果要在用户注销时清除此存储,请参阅此答案:stackoverflow.com/a/39323601/6680611

标签: angular redux ngrx


【解决方案1】:

见https://netbasal.com/how-to-secure-your-users-data-after-logout-in-redux-30468c6848e8

const reducers = {
   xxx: xxxReducer
};

export const rootReducer = (state, action) => {
  if (action.type === USER_LOGOUT) {
    state = undefined;
  }

 return combineReducers(reducers)(state, action);
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2016-06-19
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    相关资源
    最近更新 更多