tmeasday / meteor-router

MIT License
366 stars 76 forks source link

Data & waitOn functions called more than once #152

Open ahmedmelhady7 opened 8 years ago

ahmedmelhady7 commented 8 years ago

Hi,

I have the below route, and I do not understand why it gets called more than one time first returning the actual value and then returning undefined.

Router.route('/trainee/:_id', {
    name: 'traineePage',
    template: 'traineePage',
    data: function(){
        var currentTraineeId = this.params._id;
        console.log("data function "+ Meteor.users.findOne({_id: currentTraineeId}));
        return Meteor.users.findOne({_id: currentTraineeId});
    },
    waitOn: function(){
        var currentTraineeId = this.params._id;
        console.log("waitOn function "+ currentTraineeId);
        return Meteor.subscribe('traineePlans', currentTraineeId)
    }
})

I get this in the console

waitOn function nTi7xgcqg4cGZcYSn
routes.js:73 data function [object Object]
routes.js:78 waitOn function nTi7xgcqg4cGZcYSn
routes.js:73 data function [object Object]
main.js:84 traineePage.helpers.traineeName elhadiahmed
main.js:92 traineePlans.helpers.plan [object Object]
routes.js:73 data function undefined
main.js:84 traineePage.helpers.traineeName elhadiahmed
main.js:84 traineePage.helpers.traineeName undefined
main.js:92 traineePlans.helpers.plan [object Object]