Performance with Helpers vs. innerText

I have the usual method of this (Using Blaze):

Template.dashboard.onRendered(function() {
  Meteor.call('corpusCount', (error, result) => {
    if (error) {
      Session.set('corpusCount', 0);
    } else {
      Session.set('corpusCount', result);
    }
  });

then in a helper:

Template.dashboard.helpers({
  corpusCount() {
    if(Session.get('corpusCount')) {
      return Session.get('corpusCount');
    } else {
      return 0;
    }
  }

To avoid sessions, I could do this:

Meteor.call('corpusCount', (error, result) => {
    if (error) {

    } else {
      document.getElementById('accountCorpusCount').innerText = result;
    }
  });

Are there any known performance issues or benefits with either method? Or, does blaze do something like innerText under the hood with {{}}?

You could use a reactive variable

Template.dashboard.onCreated(function() {
  var instance = this;
  instance.corpusCount = new ReactiveVar(0);
  Meteor.call('corpusCount', (error, result) => {
    if (error) {
      console.error(error);
    } else {
      instance.corpusCount.set(result);
    }
});
Template.dashboard.helpers({
  corpusCount() {
   return Template.instance().corpusCount.get()
  }
}
3 Likes