diff --git a/dev-docs/publisher-api-reference/getConfig.md b/dev-docs/publisher-api-reference/getConfig.md index 9ff5f12ff9..99ac02fd88 100644 --- a/dev-docs/publisher-api-reference/getConfig.md +++ b/dev-docs/publisher-api-reference/getConfig.md @@ -4,8 +4,9 @@ title: pbjs.getConfig([string]) description: --- +## Overview -The `getConfig` function is for retrieving the current configuration object or subscribing to configuration updates. When called with no parameters, the entire config object is returned. When called with a string parameter, a single configuration property matching that parameter is returned. +The `getConfig` function is used for retrieving the current configuration object or subscribing to configuration updates. When called with no parameters, the entire config object is returned. When called with a string parameter, a single configuration property matching that parameter is returned. Be careful with use of this function, as it returns a reference to the configuration instead of a clone. The readConfig function has been introduced for safer use. {% highlight js %} /* Get config object */ @@ -15,7 +16,10 @@ config.getConfig() config.getConfig('debug') {% endhighlight %} -The `getConfig` function also contains a 'subscribe' ability that adds a callback function to a set of listeners that are invoked whenever `setConfig` is called. The subscribed function will be passed the options object that was used in the `setConfig` call. Individual topics can be subscribed to by passing a string as the first parameter and a callback function as the second. For example: + +### Subscribe + +The `getConfig` function contains a `subscribe` feature that adds a callback function to a set of listeners that are invoked whenever `setConfig` is called. The `subscribed` function will be passed the `options` object that was used in the `setConfig` call. Individual topics can be subscribed to by passing a string as the first parameter and a callback function as the second. For example: {% highlight js %} @@ -31,4 +35,4 @@ unsubscribe(); // no longer listening {% endhighlight %} -
\ No newline at end of file +
diff --git a/dev-docs/publisher-api-reference/readConfig.md b/dev-docs/publisher-api-reference/readConfig.md new file mode 100644 index 0000000000..734647e762 --- /dev/null +++ b/dev-docs/publisher-api-reference/readConfig.md @@ -0,0 +1,18 @@ +--- +layout: api_prebidjs +title: pbjs.readConfig([string]) +description: +--- + + +The `readConfig` function is used for retrieving the current configuration object or subscribing to configuration updates. When called with no parameters, the entire config object is returned. When called with a string parameter, a single configuration property matching that parameter is returned. The readConfig function has been introduced for safer use of the getConfig functionality, as it returns a clone. + +{% highlight js %} +/* Get config object */ +config.readConfig() + +/* Get debug config */ +config.readConfig('debug') +{% endhighlight %} + +