The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

featureflag - basic usage

Motivation

The featureflag package was created in order to allow R users to easily make use of feature flags. Feature flags allow developers to turn application features on and off in form of configuration. They allow to you to avoid issues related to long live branching by decoupling feature roll-out from the deployment process.

If you are interested in learning more about feature flags, check out those great resources:

Usage

library(featureflag)

The featureflag package currently supports one type of feature flags: bool feature flags (simple on and off flags). A bool feature flag can be created like this:

my_bool_feature_flag <- create_bool_feature_flag(value = TRUE)

Now you can use it in combination with the is_enabled method to branch out logic in your application:

if (is_enabled(my_bool_feature_flag)) {
  print("Running my feature...")  
}
#> [1] "Running my feature..."

In case we wanted to run some default functionality when our feature flag is off, we can simply add an else statement:

if (is_enabled(my_bool_feature_flag)) {
  print("Running my feature...")  
} else {
  print("Running my default functionality...")
}
#> [1] "Running my feature..."

featureflag offers helper methods to avoid boilerplate if and if/else code. They can be replaced by using the feature_if and feature_ifelse helpers. The above examples can be rewritten as:

feature_if(my_bool_feature_flag, {
  print("Running my feature...")
})
#> [1] "Running my feature..."
feature_ifelse(my_bool_feature_flag, {
  print("Running my feature...")
}, {
  print("Running my default_functionality...")
})
#> [1] "Running my feature..."

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.