Feature flags are conditional statements around a coded functionality in an application. Create a boolean, number, and/or string type flag in your application source code using the static API.
Create a container class and define feature flags
All flags are defined inside the required container class, and each flag name is derived from the flag variable name.
In each of the following code examples, a boolean, number and a string flag are defined.
Register the container class of feature flags and set up the SDK key
To use the container class, its instance must be registered to the platform SDK. The namespace parameter is a logical separation between containers, and is a criterion in filtering flags.
A namespace can only be registered once. |
In the following examples, a Rox SDK function is called to register the class instance, and then the environment key is set up.
Rox.register('<namespace>', flags); Rox.setup('<YOUR_SDK_KEY>');
rox := server.NewRox() rox.Register(myFlags) <-rox.Setup("<YOUR_SDK_KEY>")
Flags myFlags = new Flags(); Rox.register("<namespace>", myFlags); Rox.setup(YOUR_SDK_KEY);
# Register the container class instance to the platform SDK from rox.server.rox_server import Rox my_flags = MyContainer() Rox.register(<namespace>, my_flags) Rox.setup(<YOUR_SDK_KEY>)
Check the flag values
The following examples check the feature flag values.
# Check the boolean flag value if my_flags.video_chat.is_enabled(): print('video_chat is enabled') # Check the number flag value print('Title size is {}'.format(my_flags.title_size.get_value())) print('The special number is {}'.format(my_flags.special_number.get_value())) # Check the string flag value print('color is %s' % my_flags.title_color.get_value())
The default flag value
The default flag value, which is the flag value when configuration is disabled, is the value specified in the code.
If no value for a boolean flag is specified in your code, the default value is false
.
Number and string flags must have a default value defined for when configuration is disabled.
Flag freeze is available on client-side SDKs by default.
For SDK version 5.0 or later, the default is set to |