React Native Feature Flags
Taplytics feature flags operate in synchronous mode. Synchronous feature flags are guaranteed to have the same value for the entire session and will have that value immediately after construction.
Taplytics.featureFlagEnabled("featureFlagKey").then(isEnabled => {
if (isEnabled) {
// Put feature code here, or launch feature from here
}
});
IMPORTANT: The value of featureFlagEnabled will be determined immediately, ie. the SDK will not wait for properties to be loaded from the server. Thus, if you want to ensure that the variables have their correct variables based on your experiment segmentation, you must initialize them after the properties have been loaded from the server. This module provides a callback to achieve this:
Taplytics.propertiesLoadedCallback(() => {
Taplytics featureFlagEnabled("featureFlagKey").then(isEnabled => {
if (isEnabled) {
// Put feature code here, or launch feature from here
}
});
});
Running Feature Flags
If you would like to see which feature flags are running on a given device, there exists a getRunningFeatureFlags()
function which provides a callback with the current feature flags' names and their associated key. An example:
Taplytics.getRunningFeatureFlags().then((results) => {
// use results map
});
NOTE: The block can return asynchronously once Taplytics properties have loaded. The block will return a WritableMap
with feature flag name as the key value, and feature flag key as the value.
Updated about 4 years ago