Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spf.config without init #419

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ var spf = {};
spf.init = function(opt_config) {};


/**
* Set global configuration without initialization.
*
* @param {string} key The configuration key.
* @param {string} value The configuration value.
* @return {spf.config.Value} The configuration value.
*/
spf.config = function(key, value) {};


/**
* Disposes SPF.
*/
Expand Down
8 changes: 7 additions & 1 deletion src/client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ spf.config.init = function(opt_config) {
var config = opt_config || {};
// Set primary configs; each has a default.
for (var key in spf.config.defaults) {
var value = (key in config) ? config[key] : spf.config.defaults[key];
// config is already define with spf.config, keep define values
if (spf.config.has(key)) {
var value = (key in config) ? config[key] : spf.config.get(key);
} else {
var value = (key in config) ? config[key] : spf.config.defaults[key];
}

spf.config.set(key, value);
}
// Set advanced and experimental configs; none have defaults.
Expand Down
13 changes: 13 additions & 0 deletions src/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ spf.main.init = function(opt_config) {
};


/**
* Set global configuration without initialization.
*
* @param {string} key The configuration key.
* @param {string} value The configuration value.
* @return {spf.config.Value} The configuration value.
*/
spf.main.config = function(key, value) {
return spf.config.set(key, value);
};


/**
* Checks to see if SPF can be initialized.
*
Expand Down Expand Up @@ -101,6 +113,7 @@ spf.main.discover_();
/** @private {!Object} */
spf.main.api_ = {
'init': spf.main.init,
'config': spf.main.config,
'dispose': spf.main.dispose,
'navigate': spf.nav.navigate,
'load': spf.nav.load,
Expand Down