Skip to content
No description or website provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
test
.editorconfig
.gitignore
.npmignore
.travis.yaml
LICENSE
README.md
configurationLoader.ts
deepGet.spec.ts
deepGet.ts
deepSet.spec.ts
deepSet.ts
package-lock.json
package.json
tsconfig.json
webpack.config.js
yarn.lock

README.md

configurationLoader

Join the chat at https://gitter.im/biotope/biotope-configuration

configurationLoader.min.js loads configurations from a json file and then merges them with existing configurations using a flag (overwriteInlineConfigs) to decide which parameters should be overwritten. By default this flag is false, that is inline configurations take precedence over those set in json file. The loader returns a promise object which once resolved will give access to a configuration object. This object has also getter and setter methods which should be used to get and set configuration parameters.

Usage

configurationLoader({
	json: 'url.to.configuration.json',
	data: inline.configuration,
	overwriteInlineConfigs: [optional boolean parameter]
}).then(function(configuration) {
	window.myProject.configuration = configuration;
	window.myProject.configurationIsReady = true;
	$(window).trigger('configurationIsReady');
});

// DOM is fully loaded
$(function () {
	if (myProject.configurationIsReady) {
		myProject.init();
	} else {
		$(window).on('configurationIsReady', function() {
			myProject.init();
		});
	}
});

// It's now safe to run scripts depending on configuration parameters
myProject.init = function() {
	var test = myProject.configuration.get('nameOfProperty');
};
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.