Creating a string flag
This section describes how to define a string flag.
Understanding string flags
String flags are flags that can have multiple values and not just true or false. When you create a string flag in your application, you define the default value and all the other values this flag can have. Like simple boolean flags, the string flag name is derived from the flag variable name.
Creating a container class and defining a feature flag
To add a string flag, you need two things:
-
A container class for your flags
-
A defined flag inside the container class
In the example below, a String flag is defined with the name
titleColors
. The flag name is derived from the flag variable name. The
titleColors
flag has a default value of White
.
If you need a string flag to be more dynamic with regards to value (i.e: URL’s), you can define a String flag in the code with only one value (which is also the default value). This will result in a Free Text input field when configuring the flags through the CloudBees Feature Management dashboard. |
With SDK version 5.0 or later use Rox.RoxString, examples below: |
In the example below, the title color can be any one of White, Blue, Green and Yellow. By default, it will be white.
React Native | JavaScript | Node.js | JavaScript SSR | .NET |
---|---|---|---|---|
|
|
|
|
|
With SDK version 4.x use Rox.RoxString, examples below: |
In the example below, the title color can be any one of White, Blue, Green and Yellow. By default, it will be white.
Swift | Objective-C | Android | React Native | JavaScript | Node.js | JavaScript SSR | JVM | .NET | Python | Go | Ruby | PHP | C | C++ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Registering the container class
Once you have the container class, you need to register its instance to
the CloudBees Feature Management SDK. This is done with the Rox.register
SDK function.
The namespace parameter is a logical separation between containers and can be used to find flags on the dashboard.
|
Swift | Objective-C | Android | React Native | JavaScript | Node.js | JavaScript SSR | JVM | .NET | Python | Go | Ruby | PHP | C | C++ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Using a string flag
Swift | Objective-C | Android | React Native | JavaScript | Node.js | JavaScript SSR | JVM | .NET | Python | Go | Ruby | PHP | C | C++ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Flag freeze level Flag freeze is available on client side SDKs by default.
See Understanding a flag freeze for more information. |