Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Meteor可以处理嵌套依赖项吗?_Javascript_Meteor - Fatal编程技术网

Javascript Meteor可以处理嵌套依赖项吗?

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

如果我的Meteor autorun函数所依赖的游标本身是依赖的,那么Meteor会在最内部的依赖项每次更改时创建并保存一个新的计算吗

如果一个自动运行函数调用另一个函数的Deps.autorun怎么办

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创建并返回一个计算对象
  • 计算对象跟踪函数所依赖的所有反应数据源
  • 当任何一个反应数据源发生更改时,整个功能将重新运行
如果您需要自定义,例如仅当特定依赖项发生更改时才运行自定义自动运行,请查看