每次Meteor.user()更改时如何避免帮助程序运行

时间:2017-02-17 23:58:17

标签: meteor meteor-helper

我在Meteor中有以下帮助:

fullname(){
  return Meteor.user().currentName;
},

但每次Meteor.user()更改时,此帮助程序都会运行。我只希望它在用户的currentName更改时运行,而不仅仅是firstName

1 个答案:

答案 0 :(得分:3)

使用.findOne()并限制返回的密钥:

fullname(){
  return Meteor.users.findOne(Meteor.userId(),{fields: {currentName: 1}}).currentName;
},