UNPKG

rox-browser

Version:

Rollout.io ROX JS SDK Client

98 lines (70 loc) 3.01 kB
![Rollout](https://1ko9923xosh2dsbjsxpwqp45-wpengine.netdna-ssl.com/wp-content/themes/rollout/images/rollout_white_logo1.png) CloudBees Feature Management is a secure feature management solution for the enterprise. > Accelerate development and minimize the risk of deploying new code with simple to create feature flags, controlled rollouts, advanced target groups & deployment rules. ## Getting Started Please see the detailed instructions in our docs on how to [add CloudBees Feature Management to your project](https://support.rollout.io/docs/installing-the-sdk). ## Documentation Getting started guide, use cases, examples and videos can be found at [Rollout support site](https://support.rollout.io) # Rollout Client JavaScript SDK 🦆 [Rollout](https://rollout.io) client JavaScript SDK for web applications. Define and use simple and advanced feature flags, remote configuration variables, static and computed custom properties in code. Control your application features via Rollout's dashboard. ## Installation ``` npm i rox-browser --save ``` ## Usage Obtain an application key by registering at [Rollout.io](https://app.rollout.io). ```javascript import Rox from 'rox-browser'; const appSettingsContainer = { shouldShowWelcome: new Rox.Flag(), textColor: new Rox.RoxString('black'), textSize: new Rox.RoxNumber(12, [18, 24]) }; const onRoxReady = () => { if (appSettingsContainer.shouldShowWelcome.isEnabled()) { const color = appSettingsContainer.textColor.getValue() const size = appSettingsContainer.textSize.getValue() const div = document .createElement('div') .textContent('Hello world!') .setAttribute('style', `color: ${color}; font-size: ${size}px`); const body = document.getElementsByTagName('body')[0] body.appendChild(div) } }; Rox.register('settingsNamespace', appSettingsContainer); Rox.setup('<app key>', { configurationFetchedHandler: onRoxReady }); ``` ## Configure the SDK with different options Override the default configuration by prodiving predefined configuration preset for `Rox.setup`. For example: ```javascript import Rox from 'rox-browser'; /* - roxOptions.distinctId - roxOptions.version - roxOptions.syncComplitionHandler */ const roxOptions = { distinctId: 'sessionDistinctId', version: '1.0', configurationFetchedHandler: () => {} }; Rox.setup('<app key>', roxOptions); ``` ## Activating Manual Overrides UI You can override flags manually using a built-in UI debug utility that can be activated by invoking `Rox.showOverrides()`. Running it will display a UI element that allows to explicitly set values of flags. Available UI location of the UI element: - `'top left'` - `'top right'` - `'bottom left'` - `'bottom right' (default)` ## LICENSE Rollout client JavaScript SDK is free-to-use, proprietary software. Please see the full license found under the LICENSE file for more details. ## Feedback Feedback is always welcomed [support@rollout.io](mailto:support@rollout.io)