Meteor 背景中的流星装载集合

Meteor 背景中的流星装载集合,meteor,Meteor,我使用iron:router订阅挂钩在meteor.js应用程序的每个页面中加载所需数据(使用订阅管理器): 我还想在后台预装其他订阅(不是当前页面需要的所有订阅,但可能是当前页面需要的部分订阅);我试着插入 globalSubs = {}; Meteor.subscribe("elementsCurrentLang", Session.get('currentLang'), function() { globalSubs.globalElements = true; }); Meteo

我使用iron:router订阅挂钩在meteor.js应用程序的每个页面中加载所需数据(使用订阅管理器):

我还想在后台预装其他订阅(不是当前页面需要的所有订阅,但可能是当前页面需要的部分订阅);我试着插入

globalSubs = {};
Meteor.subscribe("elementsCurrentLang", Session.get('currentLang'), function() {
    globalSubs.globalElements = true;
});
Meteor.subscribe("municipalitiesGlobal", Session.get('currentLang'), function() {
    globalSubs.globalMunicipalities = true;
});
Meteor.subscribe("culturalGoodsGlobal", Session.get('currentLang'), function() {
    globalSubs.globalCulturalGoods = true;
});
在单独的文件subscriptions.js中,添加了如下测试,以避免重新订阅已加载的订阅:

subscriptions: function() {
    if (!globalSubs.globalElements) return subman.subscribe("neededElementsCurrentLang", Session.get('currentLang'), ['progetto']);
},
但这不起作用,因为全局订阅在页面订阅之前加载,而不是在后台加载

是否可以在后台加载3个全局订阅,避免应用程序等待加载它们(它必须只等待当前路由的订阅挂钩)


这个怎么样。

它将加载,路由器上的所有三个sub。这将在加载其他订阅之前加载这三个订阅
subscriptions: function() {
    if (!globalSubs.globalElements) return subman.subscribe("neededElementsCurrentLang", Session.get('currentLang'), ['progetto']);
},
    Router.configure({
  layoutTemplate: 'layout',
  waitOn: function(){ 
  return [Meteor.subscribe('posts'),Meteor.subscribe('colors'),Meteor.subscribe('ads')];},
  yieldTemplates:{
    'header': {to: 'header'},
    'menu': {to: 'menu'},
    'footer': {to:'footer'}
  }
});