Search code examples
meteorspacebars

Meteor: Spacebars not updating on session-value change


I have this html-File in Meteor

{{#if thevalue}}
    {{> one}}
{{else}}
    {{> two}}
{{/if}}

and this helper

'thevalue': Session.get('thevalue') //returns true or false

My problem is that when the Session-Value changes, the if/else-Bracktes from Spacebars do not change with it. I thought Session-Values are reactive...but maybe I have some sort of misconception how this works.


Solution

  • Try to write your helper as a function like so

    'thevalue': function () {
      return Session.get('thevalue');
    }
    

    See the docs here for more.