A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cran.rstudio.com/web/packages/shiny/../featureflag/vignettes/intro.html below:

featureflag - basic usage

Usage

The featureflag package currently supports the following types of feature flags: * bool feature flags - simple on and off flags * percentage feature flags - flags that are randomly enabled/disabled based on the configured percentage * time period feature flags - flags that are enabled during a specified time period e.g. from 2020-01-01 10:00:00 until 2020-02-01 10:00:00

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..."

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4