如何知道可计算观测值的来源 [英] How to know source of computed observable

查看:111
本文介绍了如何知道可计算观测值的来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当计算的可观察物取决于许多其他可观察物时,如何知道哪个可观察的变化触发了此计算的可观察物的eval函数?

When computed observable depends on many other observables, how to know which observable change triggered this computed observable's eval function?

推荐答案

找出引发computed更改的原因是不可能.

It's impossible to find out what triggered a computed's change.

相关的源文件实际上很容易紧接着,如果您深入研究它,您将看到计算的(也称为dependentObservables)可以从多种来源触发更改.哎呀,等到实际的更改通知发出时,对依赖项的多个异步调用可能导致了更改. KO库的用户都不会看到这些信息.

The relevant source file is actually quite easy to follow, and if you dig into it you'll see that a computed (a.k.a. dependentObservables) can have a change triggered from a number of sources. Heck, by the time the actual change notification goes out, multiple asynchronous calls to dependencies might have caused the change. None of that info is exposed to users of the KO library.

如果您发现自己想要这样做,则需要重新考虑您的方法.如果没有您所处环境的任何细节,就无法提供更具体的建议.

If you find yourself wanting this, you'll need to rethink your approach. Without any details on your context it's impossible to offer more specific advise though.

这篇关于如何知道可计算观测值的来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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