Redux:获取已启动操作的列表



我在我的angular项目中使用Redux将数据获取到状态,并进行一些API调用等等。我注意到Redux devtools有一个已执行的所有操作的列表。有没有办法在我的angular应用程序中获得一个动作列表?

我想将操作列表发送到后端并进一步处理它们。

有办法做到这一点吗?

我过去的做法是为商店创建一个日志中间件。这里有一个不错的例子。https://github.com/Webiks/angular-redux-middleware-example.

从本质上讲,它捕获了所有的操作,你要么根据这些操作对它们进行处理,要么返回下一个函数让商店继续

export function loggerMiddleware(store) {
return function (next) {
return function (action) {
// log a fancy message and action
console.log('Hello, this is your captain speaking.', action);
// continue to the next action
return next(action);
};
};
}

这也可以重写为如下内容,只是为了缩短它:

export const loggerMiddleware = store => next => action {
// log a fancy message and action
console.log('Hello, this is your captain speaking.', action);
// continue to the next action
return next(action);
};
};
}

这里有一个超级的破解方法,可以在30秒内将它们取出。它做了很多假设,但它可能对你有用。

https://reergymerej.github.io/blog/2019/06/14/janky-event-exports.html

  • 在控制台中键入__REDUX_DEVTOOLS_EXTENSION__
  • 双击以在VM中打开源
  • 漂亮的印花
  • 断点:356
  • 返回工具并跳到一个动作。这应该会到达您的断点
Object.keys(t.actionsById).forEach((id) =>
console.log(t["actionsById"][id].action.type))

最新更新