Improve Meteor.settings docs #4704 #5118

Fix docs to say:
* Not that Meteor.settings is empty with no settings
* Meteor.settings.public is always there on client and server
* Changing it on the server affects the client

Also add mention to History.md
This commit is contained in:
David Greenspan
2015-09-09 16:00:43 -07:00
parent 98886f98ef
commit 4df1327009
3 changed files with 10 additions and 2 deletions

View File

@@ -325,6 +325,10 @@
* Fix `Error: Can't render headers after they are sent to the client`. #4253 #4750
* `Meteor.settings.public` is always available on client and server,
and modifications made on the server (for example, during app initialization)
affect the value seen by connecting clients. #4704
### Windows
* Increase the buffer size for `netstat` when looking for running Mongo servers.

View File

@@ -25,7 +25,7 @@ Meteor = {
if (typeof __meteor_runtime_config__ === 'object' &&
__meteor_runtime_config__.PUBLIC_SETTINGS) {
/**
* @summary `Meteor.settings` contains deployment-specific configuration options. You can initialize settings by passing the `--settings` option (which takes the name of a file containing JSON data) to `meteor run` or `meteor deploy`. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the `METEOR_SETTINGS` environment variable. If you don't provide any settings, `Meteor.settings` will be an empty object. If the settings object contains a key named `public`, then `Meteor.settings.public` will be available on the client as well as the server. All other properties of `Meteor.settings` are only defined on the server.
* @summary `Meteor.settings` contains deployment-specific configuration options. You can initialize settings by passing the `--settings` option (which takes the name of a file containing JSON data) to `meteor run` or `meteor deploy`. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the `METEOR_SETTINGS` environment variable. If the settings object contains a key named `public`, then `Meteor.settings.public` will be available on the client as well as the server. All other properties of `Meteor.settings` are only defined on the server. You can rely on `Meteor.settings` and `Meteor.settings.public` being defined objects (not undefined) on both client and server even if there are no settings specified. Changes to `Meteor.settings.public` at runtime will be picked up by new client connections.
* @locus Anywhere
* @type {Object}
*/

View File

@@ -20,7 +20,11 @@ if (! Meteor.settings.public) {
Meteor.settings.public = {};
}
// Push a subset of settings to the client.
// Push a subset of settings to the client. Note that the way this
// code is written, if the app mutates `Meteor.settings.public` on the
// server, it also mutates
// `__meteor_runtime_config__.PUBLIC_SETTINGS`, and the modified
// settings will be sent to the client.
if (typeof __meteor_runtime_config__ === "object") {
__meteor_runtime_config__.PUBLIC_SETTINGS = Meteor.settings.public;
}