如何调试或检查ngrx存储,操作和效果? [英] How is it possible to debug or inspect the ngrx store, actions and effects?

查看:55
本文介绍了如何调试或检查ngrx存储,操作和效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题,我的应用程序未调度某些动作,或者在调度动作时未调用某些效果(请参阅未调用ngrx效果从组件分派动作时).

I am having issues with my application not dispatching some actions or some effects not being called when an action is dispatched (see ngrx effect not being called when action is dispatched from component).

我想知道如何调试ngrx存储,动作以及效果.

I would like to know how to debug the ngrx store, actions and also effects.

由于ngrx的打字稿源在我的环境中不可用(看来只有打字可用),还有其他方法可以了解商店中的情况和效果吗?

As the typescript sources for ngrx are not available on my environment (only the typings are available it seems), are there other ways to know what is going on in the store and effects?

P.S. 看来,开发人员存储工具仅允许查看由reducer引起的更改.

推荐答案

您发现,redux devtools扩展也是一种方便的方式来监视ngrx中的商店活动.但是,它记录所有调度的动作,包括ngrx效果发出的动作,无论减速器是否对它们进行操作以更新商店.如果您没有看到从效果中分派的动作,则说明阻止其分派是一个问题.

As you discovered, the redux devtools extension is a handy way to monitor store activity in ngrx, too. However, it records all dispatched actions, including those emitted by ngrx effects, whether reducers act on them to update the store or not. If you're not seeing actions dispatched from effects, then something else is a problem preventing their dispatch.

一种临时调试通常可观察的链(包括ngrx效果和商店订阅)的简单方法是在似乎无效的代码之前和/或之后通过.do()运算符.它不会干扰周围的代码流,它使您可以进行跟踪日志记录或添加断点以进行检查.

A simple way to temporarily debug observable chains in general, including ngrx effects and store subscriptions, is via .do() operators before and/or after code that doesn't seem to work. It doesn't perturb the flow of code around it, and it lets you do trace logging or add breakpoints for inspection.

有些人将.do()登录记录在自定义运算符中,甚至尝试自动在运算符之间插入.do()进行跟踪,以避免在各处手动编写它们.我喜欢保持简单,并在调试特定模块时临时插入它们,恕我直言.

Some people wrap .do() logging in custom operators, and there are even attempts to automate .do() insertion between operators for tracing to avoid manually writing them all over the place. I like to keep it simple, and manually inserting them temporarily when debugging specific blocks isn't so bad IMHO.

这篇关于如何调试或检查ngrx存储,操作和效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆