如何调试rxjs5? [英] How to debug rxjs5?

查看:596
本文介绍了如何调试rxjs5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RxJS - 目标中,我看到他们的目标是更好的可调试性:

On RxJS - Goals I read that their goal is better debuggability:


目标

Goals

提供比以前版本的RxJS更多的可调试调用堆栈

Provide more debuggable call stacks than preceding versions of RxJS

我刚刚开始使用 redux-observable ,这比我更容易理解,将其与我已经习惯了使用 lodash ramda 的反应式样式好的,fp风格也许;)。我很惊讶,它是不可能调试它。是真的吗如果是这样,那么我必须切换到 redux-saga ,或者坚持使用 redux-thunk

I have just started to use redux-observable which is quite easier for me to understand comparing it to redux-saga as I am already used to the reactive style with lodash and ramda (ok, fp style maybe ;). I was surprised that it's not possible to debug it yet. Is it true? If so, then I gotta switch to redux-sagas maybe or stick with redux-thunk.

根据Jay Phelps的回答编辑

通过调试我的意思是:如何设置断点在浏览器中例如 observable.map(...)?使用 lodash 我可以在浏览器中设置一个断点,并在 _。map(...)。如何使用 redux-observable (或 rxjs )?我不想依赖大理石图的绘制和 console.log()

By debugging I meant: "How to set a breakpoint on e.g. observable.map(...) in a browser?" With lodash I can set a breakpoint in the browser and it stops right there on the _.map(...). How to do it with redux-observable (or rxjs)? I don't want to depend on drawing of marble diagrams and console.log().

推荐答案

当然可以调试RxJS代码。我认为很可能安全的说,几乎没有人会使用它,如果不是这样的情况 - Angular2也是建立在它上面。

It certainly is possible to debug RxJS code. I think it's probably safe to say hardly anyone would use it if that wasn't the case--Angular2 is heavily built on it too.

人们最常用的方式与调试其他JavaScript,断点(例如调试器)和console.log()的

The most common ways people use are the same ways they debug other JavaScript, breakpoints (e.g. debugger) and console.log()'s

相同的方法有一些用户使用的更先进的技术,如绘制依赖图或大理石图。 安德烈·斯塔尔兹(AndréStaltz)最近写了这个,所以这可能是一个有用的资源。

There are more advanced techniques some users use like drawing dependency graphs or marble diagrams. André Staltz wrote about this recently, so that might be a helpful resource.

最终,任何类型的异步编程将更难调试。这不是redux-observable / RxJS唯一的;快速搜索将会显示出许多针对redux-saga的调试问题。

Ultimately, any kind of async programming is going to be harder to debug. This is not unique to redux-observable/RxJS; a quick search will reveal plenty of debugging concerns for redux-saga too.

事实证明,redux-thunk是绝大多数应用程序的最佳解决方案,因为他们中的大多数没有复杂的副作用关注,例如像redux-observable或redux-saga这样的理由。虽然如果您已经熟练使用RxJS,则使用redux-observable可以避免使用

It turns out that redux-thunk is the best solution for a vast majority of applications built because a majority of them do not have complex side effect concerns that justify something like redux-observable or redux-saga. Though if you are already proficient in RxJS, there's nothing wrong with using redux-observable.

reducex-saga作为项目存在时间长于这是可观察的,这当然是一个主要的卖点。你会发现更多的文档,例子,并有可能有一个更好的社区来获得支持。

redux-saga as a project has existed longer than redux-observable so that's certainly one major selling point. You'll find more documentation, examples, and likely are have a better community to get support from.

计数器是你在redux-saga中学习的运算符和API并不像学习RxJS那样可以转移,而是在所有地方使用。 redux-observable是内部简单的超级超级超级,它只是给你一个自然的方式来使用RxJS。所以如果你知道RxJS(或想要),这是非常自然的。

The counter being that the operators and APIs you learn in redux-saga aren't nearly as transferable as learning RxJS, which is used all over the place. redux-observable is super super super simple internally, it's really just giving you a natural way for you to use RxJS. So if you know RxJS (or want to), it's an extremely natural fit.

我现在对大多数人的建议是,如果你必须问你哪一个你应该使用,你可能应该选择redux-saga。

My advice at the moment for most people is that if you have to ask which one you should use, you probably should choose redux-saga.

(免责声明:我是redux-observable和RxJS v5的维护者之一)

(disclaimer: I am one of the maintainers of redux-observable and RxJS v5)

这篇关于如何调试rxjs5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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