1
フロー・ルーターを備えた流星アプリでは、ユーザー・データのフェッチに流星サブスクリプションを使用していますが、私のクライアントコードで私の出版物コードでフロー・ルーターを使用したテンプレート・ヘルパーのmeteor.userサブスクリプションへのアクセス
、私router.jsファイルで
Meteor.publish('fetchUserData', function(usrnm) {
return Meteor.users.find({'username':usrnm}, {
fields: {
profile: true,
services: true,
emails: true,
votedPatents: true,
userType: true,
followingUsers: true,
followedByUsers: true
}
});
});
、
Subs = new SubsManager();
FlowRouter.route('/:username', {
subscriptions: function(params) {
this.register('fetchUserData', Meteor.subscribe('fetchUserData', params.username));
},
action: function(params) {
BlazeLayout.render('main', {center: 'profile'});
})
}
});
Template.profile.onCreated(function() {
this.autorun(function() {
var handle = Subs.subscribe('fetchUserData', username);
})
})
Template.profile.helpers({
connections: function(){
var u = Meteor.users.findOne({'username':username});
return u;
}
})
また、ヘルパー関数が未定義返すことに注意してくださいMeteor.user()以外のユーザーの場合はHow to access FlowRouter subscriptions in Meteor template helpers?も試してみましたが、その結果同じです