简体   繁体   English

流星:启动和数据加载

[英]Meteor: startup and data loading

Because findOne is returning undefined for some data, I tried to set up a Session variable like this: 因为findOne对于某些数据返回未定义,所以我尝试设置一个Session变量,如下所示:

Meteor.startup(function(){
  Session.set('drawingsLoaded', false);
})

Deps.autorun(function(){
  Meteor.subscribe('allDrawings', function(){  
    Session.set('drawingsLoaded', true);    
    console.log(Session.get('drawingsLoaded'))
  });

Console logs true. 控制台日志为true。 But when I interactively enter 但是当我以交互方式进入

Session.get('drawingsLoaded')

it's returning false. 它返回假。

I have no idea why and so my data is not displaying probably because of this. 我不知道为什么,因此我的数据可能无法显示。 I am very confused why this is returning false even though I did not set drawingsLoaded anywhere else other than startup 我很困惑,为什么即使我没有设置DrawingLoaded到启动以外的其他地方,却返回false

如果这是您的实际代码,则可能在传递给Meteor.startup的回调之前调用传递给订阅的ready callback?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM