Template iterating over a Method Call

Hi,

I have a table that am constructing from various calculations for each user; being done inside a server method. The template understandably renders way before the method’s response every single user is back; and even then - I wouldn’t want to hold it back.

in the template - which can have many users to iterate through is part of an {{#each}} directive

..
{{ userEventCount this._id 'assigned' }}
..

My userEventCount helper definition:

userEventCount: function (userId, status) {
    userId ? check(userId, String) : null;
    status ? check(status, String) : null;

    Meteor.call('getUserEvents', userId, status, FlowRouter.getParam('calendarId'), function (err, res) {
      if (!err) {
        Session.set('hh_getUserEvents_' + userId, res.length);
      }
    });

    return Session.get('hh_getUserEvents_' + userId);
  }

Ideally - I’d like to not pollute the session space for “working out" - after all - each user is unique - hence the appending of the _id.

Does anyone has a better way of doing this? Is there a pattern for this type of problem that I could follow ?

Am certain this comes up quite often. Searching didn’t yield anything immediately useful. Insight appreciated.

Thank you.

Define your meteor call inside onCreated’s this.autorun.
And helper should be just dumb return Session.get('hh_getUserEvents_' + userId);

thanks @shock . What’s the means of argument passing to autorun then?

For begginers using Session inside autorun and setting it in event handler or so
For more advanced users, template level reactive vars most of the time.