How to update a variable's value reactively from 'Meteor startup'


#1

Hi, I am trying to add some general app configuration for a project I am working on, and I decided to save this on the database so that I can change them from some other place if things go wrong with the app, the main reason I am doing this is to add a ‘maintenance mode’ whenever I am making changes to the app or during deploys or something like that, the way I’m trying do this is with a variable I set with this code:

 Meteor.startup(function() {
  Tracker.autorun(function () {
    Meteor.subscribe('configuracion', function(){
      configuracionGeneral = Configuracion.findOne({});
    })
  });
});

However, when I try to use it like this with iron router:

Router.onBeforeAction(function () {
  console.log(configuracionGeneral);
  if(configuracionGeneral.vynoHabilitado=='habilitado'){
    this.next();
  }else{
    //Send to maintenance template
  }
});

I can use the variable configuracionGeneral with no problem and I see it on the console, but when I change the values of it on the database the variable doesn’t change ‘reactively’, so I would like to know how can I change this variable ‘reactively’.


#2

Have you looked at https://github.com/ogourment/settings ?


#3

Thanks for the link, the thing is that I would like to change the settings from the database, so that I can change them without the need to re-deploy my code in case I need to change something. And with this package I am afraid I would need to re-deploy my app everytime I had to change the settings, and that is something I am currently having a lot of trouble with. (hot code push on Cordova)