Javascript Meteor可以处理嵌套依赖项吗?
如果我的Meteor autorun函数所依赖的游标本身是依赖的,那么Meteor会在最内部的依赖项每次更改时创建并保存一个新的计算吗 如果一个自动运行函数调用另一个函数的Deps.autorun怎么办Javascript Meteor可以处理嵌套依赖项吗?,javascript,meteor,Javascript,Meteor,如果我的Meteor autorun函数所依赖的游标本身是依赖的,那么Meteor会在最内部的依赖项每次更改时创建并保存一个新的计算吗 如果一个自动运行函数调用另一个函数的Deps.autorun怎么办 Session.set('fooVal', 33); myComputation = Deps.autorun(function() { if (typeof(myComputation) !== 'undefined') myComputation.stop(); // Is t
Session.set('fooVal', 33);
myComputation = Deps.autorun(function() {
if (typeof(myComputation) !== 'undefined')
myComputation.stop(); // Is this needed to prevent Computation accumulation?
var foos = BarCollection.find({foo:Session.get('fooVal')};
/* Do stuff with foos */
});
Session.set('fooVal', 33);
Session.set('fooVal', 34);
Session.set('fooVal', 35);
Meteor可以使用反应数据作为集合查询中的键或值。仔细阅读文档中的部分 自动运行函数可以嵌套而不存在内存泄漏。如果内部自动运行块无效,则仅重新运行内部块。如果外部自动运行块无效,则重新运行两个自动运行块 重要的是要了解:
- Deps.autorun创建并返回一个计算对象李>
- 计算对象跟踪函数所依赖的所有反应数据源
- 当任何一个反应数据源发生更改时,整个功能将重新运行李>