Meteor.subscribe回调函数,保存到Session但返回undefined

时间:2014-12-23 12:19:51

标签: meteor publish-subscribe reactive-programming

我在/ client /

中有这个profile.js文件
/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
✚  subscribe
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/

    var currentUser, currentUserInterests

    Meteor.subscribe("tikiUser", function(){

        Session.set("currentTikiUser", tikiUser.find({}).fetch())

    })


/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
✚  helpers
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/

    Template.profileTags.helpers({

        isActive:function(){

            currentUser = Session.get("currentTikiUser")
            currentUserInterests = currentUser.userInterests

            console.log(currentUserInterests)


        }

    })

我正在尝试获取currentUser.userInterests中的值(在我的帮助器中),但它总是返回“undefined”。但是,如果我在帮助器中的console.log(currentUser),我得到了正确的对象,但只是第一次。第二次(当我刷新页面时)我得到了这个例子:

  • 模板助手中的异常:.isActive

为什么?

THX,

0 个答案:

没有答案
相关问题