【发布时间】:2014-08-13 21:12:28
【问题描述】:
这是我的路线:
this.route('friends', {
path: '/friends',
waitOn: function() {
return Meteor.subscribe('friendsPlaylists', Session.get('friends'))
}
});
在这条路线之前,我调用了一个访问 api 的函数,并设置了一个会话值:
Router.onBeforeAction(getFriends, {only: 'friends'})
var getFriends = function() {
Meteor.call('getFriendsData', function(err, result) {
Session.set('friends', result.data);
Session.set('friendsLoaded', true);
});
}
返回 Meteor.subscribe 时,由于异步行为,会话未设置。如何让订阅工作,它将在哪里等待会话设置?提前感谢您的任何帮助!
【问题讨论】:
标签: meteor