As title says, i need to know when the Meteor.settings object is initialized.

What i want to do is, create this object in advance with some default values and overwrite any of these values with the values from the settings file when the object is initialized by meteor.

Atm i apply default values like this:


{ "foo" : { "bar":true } }


bar = == undefined ? false :;

Which i will have to do for every property...

And it would be much nicer just to create the object in advance and overwrite the properties when they are present in the settings file.

Update: Ok i found the problem....

I was setting the right outside a function:

var foo =

So it was not defined at this point. But later in the function when i accesed the property i did not get the updated reference to;

Anyways thx for the help.

Meteor.settings will be loaded right from the moment server started. However, you can override that object any times you want. I normally put the overriding in the server/main.js, inside Meteor.startup .

// server/main.js Meteor.startup(() => { Meteor.settings = {} // your new object })

However, be careful about the overriding. Throughout the system, it should be done one time and in one place so everything is consistent.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

本文标题:When and where is the Meteor.settings object initialized&ques ...

技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(78)