Feature Flags - How to use

General

Feature flags allow display and hide new and old features implemented inside a system.

Existing Feature flags

WLM Demo Portal have two flag implemented for the moment:

  1. Default Activities - appsetting.json/AddDefaultActivitiesAndTimes

  2. Session Expiry popup - appsetting.json/DisplaySessionExpiryPopup

 

The flags are just true/false values to switch a corresponding feature on and off.

It is important so the flags will be part of configuration file and not hardcoded inside the code. In such a way we always can update the flag without recompiling the code.

Usage inside WLM Demo Portal

Whenever we need a flag to be used, we have to read it from configuration settings. Usually is it done inside a constructor or inside OnInitializeAsync() method

Example:

DisplaySessionExpiryPopup = _configuration.GetValue<bool>("DisplaySessionExpiryPopup");

 

From this moment the variable can be used as a condition:

if (DisplaySessionExpiryPopup) { //some code here }