YCB Config 提供了一个简单的 API 去访问和配置 Yahoo 配置捆绑文件,并可以无视文件使用格式。它也提供了一个缓存层来减少 YCB 模块对进程的调用。
示例代码:
// This contextual information is usually obtained from some custom middleware in your application. var context = { 'device': 'iphone', 'locale': 'en-US', 'bucket': 'new-feature-x'}; // This requires that the config we're reading has already been added through `addConfig`. helper.read('homepage', 'weather-widget', context, function (err, config) { /** * The `config` object now contains the correct configuration settings for * our context above. You can use it to render a template correctly for an * iPhone, with the right localization settings for the US, and with the new * feature you're bucket testing for. */});